Dynamic updating of scheduling hierarchy in a traffic manager of a network processor

ABSTRACT

Described embodiments provide for dynamically controlling a scheduling rate of each node in a scheduling hierarchy of a network processor. A traffic manager generates a tree scheduling hierarchy having a root scheduler and N scheduler levels. The network processor generates tasks corresponding to received packets. A traffic manager enqueues received tasks in a queue of the scheduling hierarchy associated with a data flow. The queue has a parent scheduler at each level of the hierarchy up to the root scheduler. The traffic manager maintains one or more scheduling data structures for each node in the scheduling hierarchy. If the traffic manager receives a rate reduction request corresponding to a given node of the scheduling hierarchy, the traffic manager updates one or more indicators in the scheduling data structure corresponding to the given node and removes the given node from the scheduling hierarchy, thereby reducing the scheduling rate of the node.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the benefit of the filing date of U.S.provisional application No. 61/388,962, filed Oct. 1, 2010, theteachings of which are incorporated herein in their entireties byreference.

This application is a continuation-in-part, and claims the benefit ofthe filing date, of U.S. patent application Ser. Nos. 12/782,379 filedMay 18, 2010, 12/782,393 filed May 18, 2010, and 12/782,411 filed May18, 2010, the teachings of which are incorporated herein in theirentireties by reference.

The subject matter of this application is related to U.S. patentapplication Ser. Nos. 12/430,438 filed Apr. 27, 2009, 12/729,226 filedMar. 22, 2010, 12/729,231 filed Mar. 22, 2010, 12/963,895 filed Dec. 9,2010, 12/971,742 filed Dec. 17, 2010, 12/974,477 filed Dec. 21, 2010,12/975,823 filed Dec. 22, 2010, 12/975,880 filed Dec. 22, 2010,12/976,045 filed Dec. 22, 2010, 12/976,228 filed Dec. 22, 2010,12/979,551 filed Dec. 28, 2010, 12/979,665 filed Dec. 28, 2010,12/979,800 filed Dec. 28, 2010, 13/046,717 filed Mar. 12, 2011,13/046,719 filed Mar. 12, 2011, 13/046,726 filed Mar. 12, 2011,13/192,104 filed Jul. 27, 2011, 13/192,140 filed Jul. 27, 2011,13/192,187 filed Jul. 27, 2011, 13/232,422 filed Sep. 14, 2011, ______(having attorney docket number L10-0359US1) filed on common dateherewith, ______ (having attorney docket number L10-0361US1) filed oncommon date herewith, ______ (having attorney docket number L10-0367US1)filed on common date herewith, ______ (having attorney docket numberL10-0376US1) filed on common date herewith, ______ (having attorneydocket number L10-0388US1) filed on common date herewith, ______ (havingattorney docket number L10-0390US1) filed on common date herewith,______ (having attorney docket number L10-0397US1) filed on common dateherewith, ______ (having attorney docket number L10-0399US1) filed oncommon date herewith, ______ (having attorney docket number L10-0477US1)filed on common date herewith, ______ (having attorney docket numberL10-0480US1) filed on common date herewith, ______ (having attorneydocket number L10-0487US1) filed on common date herewith, and ______(having attorney docket number L11-1638US1) filed on common dateherewith, the teachings of which are incorporated herein in theirentireties by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to communication systems, in particular,to data caching and coherency maintenance for an accelerated processorarchitecture for packet networks.

2. Description of the Related Art

Network processors are generally used for analyzing and processingpacket data for routing and switching packets in a variety ofapplications, such as network surveillance, video transmission, protocolconversion, voice processing, and internet traffic routing. Early typesof network processors were based on software-based approaches withgeneral-purpose processors, either singly or in a multi-coreimplementation, but such software-based approaches are slow. Further,increasing the number of general-purpose processors diminishedperformance improvements, or actually slowed down overall networkprocessor throughput. Newer designs add hardware accelerators to offloadcertain tasks from the general-purpose processors, such asencryption/decryption, packet data inspections, and the like. Thesenewer network processor designs are traditionally implemented witheither i) a non-pipelined architecture or ii) a fixed-pipelinearchitecture.

In a typical non-pipelined architecture, general-purpose processors areresponsible for each action taken by acceleration functions. Anon-pipelined architecture provides great flexibility in that thegeneral-purpose processors can make decisions on a dynamic,packet-by-packet basis, thus providing data packets only to theaccelerators or other processors that are required to process eachpacket. However, significant software overhead is involved in thosecases where multiple accelerator actions might occur in sequence.

In a typical fixed-pipeline architecture, packet data flows through thegeneral-purpose processors and/or accelerators in a fixed sequenceregardless of whether a particular processor or accelerator is requiredto process a given packet. This fixed sequence might add significantoverhead to packet processing and has limited flexibility to handle newprotocols, limiting the advantage provided by using the accelerators.Network processors implemented as a system on chip (SoC) having multipleprocessing modules might typically classify an incoming packet todetermine which of the processing modules will perform operations forthe particular packet or flow of packets.

A network processor in a switching network might provide transport ofreceived data packets from an input port to one (unicast) or more(multicast) output ports of the network. Received data packets areprovided to one or more output ports according to a schedulingalgorithm. Traditionally, a network processor includes a traffic managerto schedule packets for transmission by the network processor based on ascheduling hierarchy. A scheduling hierarchy might be a tree structureof queues and schedulers. Each scheduler performs arbitration to pick aneligible child node for transmission in each scheduling cycle such thata packet is typically scheduled for transmission in each schedulingcycle of the network processor.

SUMMARY OF THE INVENTION

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used to limit the scope of the claimed subject matter.

Described embodiments provide for dynamically controlling a schedulingrate of each node in a scheduling hierarchy of a network processor. Atraffic manager generates a scheduling hierarchy that is a treestructure having a root scheduler and N scheduler levels. The networkprocessor generates tasks corresponding to received packets. A trafficmanager enqueues received tasks in a queue of the scheduling hierarchyassociated with a data flow of the task. The queue has a parentscheduler at each level of the hierarchy up to the root scheduler. Thetraffic manager maintains one or more scheduling data structures foreach node in the scheduling hierarchy. If the traffic manager receives arate reduction request corresponding to a given node of the schedulinghierarchy, the traffic manager updates one or more indicators in thescheduling data structure corresponding to the given node and removesthe given node from the scheduling hierarchy, thereby reducing thescheduling rate of the given node.

BRIEF DESCRIPTION OF THE DRAWINGS

Other aspects, features, and advantages of the present invention willbecome more fully apparent from the following detailed description, theappended claims, and the accompanying drawings in which like referencenumerals identify similar or identical elements.

FIG. 1 shows a block diagram of a network processor operating inaccordance with exemplary embodiments of the present invention;

FIG. 2 shows a block diagram of a system cache of the network processorof FIG. 1;

FIG. 3 shows a block diagram of a traffic manager of the networkprocessor of FIG. 1, in accordance with embodiments of the presentinvention;

FIG. 4 shows an exemplary scheduler and queue hierarchy of the trafficmanager of FIG. 3, in accordance with embodiments of the presentinvention;

FIG. 5 shows an exemplary block diagram of a task provided to thetraffic manager of FIG. 3, in accordance with embodiments of the presentinvention;

FIG. 6 shows a flow diagram of a task processing routine of the trafficmanager of FIG. 3, in accordance with embodiments of the presentinvention;

FIG. 7 shows a flow diagram of a task enqueue sub-process of the taskprocessing routine of FIG. 6, in accordance with embodiments of thepresent invention;

FIG. 8 shows a flow diagram of a task scheduling sub-process of the taskprocessing routine of FIG. 6, in accordance with embodiments of thepresent invention;

FIG. 9 shows a flow diagram of a task dequeue sub-process of the taskprocessing routine of FIG. 6, in accordance with embodiments of thepresent invention;

FIG. 10 shows a flow diagram of an exemplary round robin schedulingprocess of the traffic manager of FIG. 3, in accordance with embodimentsof the present invention;

FIG. 11 shows a flow diagram of another exemplary round robin schedulingprocess of the traffic manager of FIG. 3, in accordance with embodimentsof the present invention;

FIG. 12 shows a flow diagram of a strict priority scheduling method ofthe traffic manager of FIG. 3, in accordance with embodiments of thepresent invention;

FIG. 13 shows a flow diagram of a minimum rate scaling method of thetraffic manager of FIG. 3, in accordance with embodiments of the presentinvention;

FIG. 14 shows a block diagram of an exemplary task queue structure ofthe traffic manager of FIG. 3, in accordance with embodiments of thepresent invention;

FIG. 15 shows a flow diagram of a task drain process of the trafficmanager of FIG. 3, in accordance with embodiments of the presentinvention;

FIG. 16 shows a flow diagram of a multi-thread task data read requestoperation of the traffic manager of FIG. 3, in accordance withembodiments of the present invention;

FIG. 17 shows a flow diagram of a thread processing method of themulti-thread task data read request operation of FIG. 16, in accordancewith embodiments of the present invention;

FIG. 18 shows a flow diagram of a backpressure or timer request processof the traffic manager of FIG. 3, in accordance with embodiments of thepresent invention;

FIG. 19 shows a logical block diagram of a queue engine of the trafficmanager of FIG. 3, in accordance with embodiments of the presentinvention;

FIG. 20 shows a flow diagram of a memory access request process of thetraffic manager of FIG. 3, in accordance with embodiments of the presentinvention; and

FIG. 21 shows a flow diagram of a memory lock release process of thetraffic manager of FIG. 3, in accordance with embodiments of the presentinvention.

DETAILED DESCRIPTION

Described embodiments of the present invention provide a Modular TrafficManager (MTM) for a multi-core, multi-threaded network processor.

Table 1 defines a list of acronyms employed throughout thisspecification as an aid to understanding the described embodiments ofthe present invention:

TABLE 1 USB Universal Serial Bus FIFO First-In, First-Out SATA SerialAdvanced I/O Input/Output Technology Attachment SCSI Small ComputerSystem DDR Double Data Rate Interface SAS Serial Attached SCSI DRAMDynamic Random Access Memory PCI-E Peripheral Component MMB MemoryManager Interconnect Express Block SRIO Serial RapidIO CPU CentralProcessing Unit SoC System-on-Chip μP Microprocessor AXI AdvancedeXtensible PLB Processor Local Bus Interface AMBA Advanced Micro- MPPModular Packet controller Bus Processor Architecture PAB Packet AssemblyBlock AAL5 ATM Adaptation Layer 5 MTM Modular Traffic Manager SED StreamEditor DBC Data Buffer Controller THID Thread Identifier HE Hash EnginePQM Pre-Queue Modifier SENG State Engine FBI Function Bus Interface TIDTask Identifier CCL Classification Com- pletion List SCH Scheduler SEMSemaphore Engine SPP Security Protocol PCM Per Context Memory ProcessorTIL Task Input Logic PDU Protocol Data Unit TCP Transmission Control PICPacket Integrity Checker Protocol TS Traffic Shaper FSM Finite StateMachine PCR Peak Cell Rate MCR Minimum Cell Rate EF Expedited ForwardingAF Assured Forwarding BE Best Effort Forwarding SDWRR Smooth DeficitWeighted Round Robin mutex MUtually EXclusive CRC Cyclic RedundancyCheck IP Internet Protocol

FIG. 1 shows a block diagram of an exemplary network processor system(network processor 100) implemented as a system-on-chip (SoC). Networkprocessor 100 might be used for processing data packets, performingprotocol conversion, encrypting and decrypting data packets, or thelike. As shown in FIG. 1, network processor 100 includes on-chip sharedmemory 112, one or more input-output (I/O) interfaces collectively shownas I/O interface 104, one or more microprocessor (μP) cores 106 ₁-106_(M), and one or more hardware accelerators 108 ₁-108 _(N), where M isan integer greater than or equal to 0, and N is a positive integer.Network processor 100 also includes external memory interface 114 forcommunication with external memory 116. External memory 116 mighttypically be implemented as a dynamic random-access memory (DRAM), suchas a double-data-rate three (DDR-3) DRAM, for off-chip storage of data.In some embodiments, such as shown in FIG. 1, each of the one or moreI/O interfaces, μP cores and hardware accelerators might be coupledthrough switch 110 to shared memory 112. Switch 110 might be implementedas a non-blocking crossbar switch such as described in related U.S.patent application Ser. Nos. 12/430,438 filed Apr. 27, 2009, 12/729,226filed Mar. 22, 2010, and 12/729,231 filed Mar. 22, 2010, which areincorporated by reference herein.

I/O interface 104 might typically be implemented as hardware thatconnects network processor 100 to one or more external devices throughI/O communication link 102. I/O communication link 102 might generallybe employed for communication with one or more external devices, such asa computer system or networking device, which interface with networkprocessor 100. I/O communication link 102 might be a custom-designedcommunication link, or might conform to a standard communicationprotocol such as, for example, a Small Computer System Interface(“SCSI”) protocol bus, a Serial Attached SCSI (“SAS”) protocol bus, aSerial Advanced Technology Attachment (“SATA”) protocol bus, a UniversalSerial Bus (“USB”), an Ethernet link, an IEEE 802.11 link, an IEEE802.15 link, an IEEE 802.16 link, a Peripheral Component InterconnectExpress (“PCI-E”) link, a Serial Rapid I/O (“SRIO”) link, or any otherinterface link. Received packets are preferably placed in a buffer inshared memory 112 by transfer between I/O interface 104 and sharedmemory 112 through switch 110.

In embodiments of the present invention, shared memory 112 is aconventional memory operating as a cache that might be allocated and/orsubdivided. For example, shared memory 112 might include one or moreFIFO queues that might be dynamically allocated to the various μP cores106 and hardware accelerators 108. External memory interface 114 couplesshared memory 112 to one or more external memories, shown as externalmemory 116, to provide off-chip storage of data not needed by thevarious μP cores 106 and hardware accelerators 108 to free space inshared memory 112. The μP cores and hardware accelerators might interactwith each other, for example, by one or more communication bus rings 118that pass “tasks” from a source core to a destination core. As describedherein, tasks are instructions to the destination core to performcertain functions, and a task might contain address pointers to datastored in shared memory 112, as described in related U.S. patentapplication Ser. Nos. 12/782,379, 12/782,393, and 12/782,411, all filedMay 18, 2010, which are incorporated by reference herein.

Network processor 100 might typically receive data packets from one ormore source devices, perform processing operations for the received datapackets, and transmit data packets out to one or more destinationdevices. As shown in FIG. 1, one or more data packets are transmittedfrom a transmitting device (not shown) to network processor 100, via I/Ocommunication link 102. Network processor 100 might receive data packetsfrom one or more active data streams concurrently from I/O communicationlink 102. I/O interface 104 might parse the received data packet andprovide the received data packet, via switch 110, to a buffer in sharedmemory 112. I/O interface 104 provides various types of I/O interfacefunctions and, in exemplary embodiments described herein, is acommand-driven hardware accelerator that connects network processor 100to external devices. Received packets are preferably placed in sharedmemory 112 and then one or more corresponding tasks are generated.Transmitted packets are preferably generated from data in shared memory112 for one or more corresponding tasks and might be transmittedexternally of network processor 100. Exemplary I/O interfaces includeEthernet I/O adapters providing integrity checks of incoming data. TheI/O adapters might also provide timestamp data for received andtransmitted packets that might be used to implement features such astiming over packet (e.g., specified in the standard recommendations ofIEEE 1588). In alternative embodiments, I/O interface 104 might beimplemented as input (receive) only or output (transmit) onlyinterfaces.

The various μP cores 106 and hardware accelerators 108 of networkprocessor 100 might include several exemplary types of processors oraccelerators. For example, the various μP cores 106 might be implementedas Pentium® or Power PC® processors, or a combination of differentprocessor types (Pentium® is a registered trademark of IntelCorporation, and Power PC® is a registered trademark of IBM). Thevarious hardware accelerators 108 might include, for example, one ormore function-specific modules, such as a Modular Packet Processor(MPP), a Packet Assembly Block (PAB), a Modular Traffic Manager (MTM), aMemory Management Block (MMB), a Stream Editor (SED), a SecurityProtocol Processor (SPP), a Regular Expression (RegEx) engine, and otherspecial-purpose modules.

The SED is a software-driven accelerator that allows for editing ofpackets. The SED performs packet editing functions that might includeadding and modifying packet headers as well as fragmenting or segmentingdata (e.g., IP fragmentation). The SED receives packet data as well asparameters from tasks and a task specified per-flow state. The output ofthe SED can become the outgoing packet data and can also update taskparameters.

The RegEx engine is a packet search engine for state-based cross-packetpattern matching. The RegEx engine is multi-threaded accelerator. Anexemplary RegEx engine might be implemented such as described in U.S.Pat. Nos. 7,439,652 and 7,899,904, the teachings of which areincorporated by reference herein in their entireties.

The SPP provides encryption/decryption capabilities and is acommand-driven hardware accelerator, preferably having the flexibilityto handle protocol variability and changing standards with the abilityto add security protocols with firmware upgrades. The ciphers andintegrity (hash) functions might be implemented in hardware. The SPP hasa multiple ordered task queue mechanism, discussed in more detail below,that is employed for load balancing across the threads.

The MMB allocates and frees memory resources in shared memory 112.Memory is allocated for such applications as task FIFO storage, packetdata storage, hash-table collision handling, timer event management, andtraffic manager queues. The MMB provides reference counts to each blockof memory within shared memory 112. Multiple reference counts allow formore efficient storage of information, such as multicast traffic (datato be sent to multiple destinations) or for retransmission. Multiplereference counts remove a need for replicating data each time the datais needed. The MMB preferably tracks the memory allocations using astack-based approach since a memory block recently released ispreferably the next block to be allocated for a particular task,reducing cache trashing and cache tracking overhead. Blocks in sharedmemory 112 might be dynamically allocated by the MMB to store data, withthe blocks in one of the following sizes: 256, 2048, 16384, and 65536bytes. The MMB might operate substantially as described in related U.S.patent application Ser. No. 12/963,895 filed Dec. 9, 2010, which isincorporated by reference herein.

The PAB is a command driven hardware accelerator providing a holdingbuffer with packet assembly, transmit, retransmit, and deletecapabilities. An incoming task to the PAB can specify to insert/extractdata from anywhere in any assembly buffer. Gaps are supported in anybuffer. Locations to insert and extract can be specified to the bitlevel. Exemplary traditional packet reassembly functions might besupported, such as IP defragmentation. The PAB might also supportgeneralized holding buffer and sliding window protocoltransmit/retransmit buffering, providing an offload for features likeTCP origination, termination, and normalization. The PAB might operatesubstantially as described in related U.S. patent application Ser. No.12/971,742 filed Dec. 17, 2010, which is incorporated by referenceherein.

The MPP is a multi-threaded special purpose processor that provides treebased longest prefix and access control list classification. The MPPalso has a hardware hash-based classification capability with fullhardware management of hash-table additions, deletions, and collisions.Optionally associated with each hash entry is a timer that might be usedunder software control for tasks such as connection timeout andretransmission timing. The MPP contains a statistics and statemanagement engine, which when combined with the hash table and timerfacilities, provides support for state-based protocol processing. TheMPP might support millions of flows, limited only by the amount of DRAMcapacity assigned to the functions. The MPP architecture might be ableto store all per thread states in memory instead of in register files.The MPP might operate substantially as described in related U.S. patentapplication Ser. Nos. 12/974,477 filed Dec. 21, 2010, 12/975,823,12/975,880, 12/976,045, and 12/976,228 all filed Dec. 22, 2010, whichare incorporated by reference herein. The MPP might also include hashfunctionality such as described in related U.S. patent application Ser.Nos. 13/046,717, 13/046,719, and 13/046,726 all filed Mar. 12, 2011,which are incorporated by reference herein.

As will be described herein, the MTM is a software-driven acceleratorthat provides packet scheduling and possibly up to six levels ofscheduling hierarchy. The MTM might support millions of queues andschedulers (enabling per flow queuing if desired). The MTM might providesupport for shaping and scheduling with smooth deficit weighted roundrobin (SDWRR) for every queue and scheduler. The MTM might also supportmulticasting. Each copy of a packet is scheduled independently andtraverses down different virtual pipelines enabling multicast withindependent encapsulations or any other processing. The MTM might alsocontain a special purpose processor that can be used for fine-grainedcontrol of scheduling decisions. The MTM might be used to make discarddecisions as well as scheduling and shaping decisions.

FIG. 2 shows a block diagram of an exemplary embodiment of system cache200 of network processor 100, in accordance with embodiments of thepresent invention. As shown in FIG. 2, system cache 200 might beimplemented in shared memory 112. System cache 200 might include one ormore sub-caches, shown as sub-caches 202(1)-202(N). Sub-caches202(1)-202(N) might be employed to cache data from any μP core oraccelerator (e.g., μP cores 106 or accelerators 108) of networkprocessor 100. As indicated by dashed line 210, shared memory 112 andexternal memory 116 might generally be referred to as system memory 212.

As described in related U.S. patent application Ser. Nos. 12/782,379,12/782,393, and 12/782,411, which are incorporated by reference herein,sub-caches 202(1)-202(N) might be addressed via switch 110 in such a wayas to balance access to the caches, referred to herein as striping,helping to avoid hot spots in shared memory 112, improve performance ofthe caching in and out of external memory 116, and reduce cache accessbottlenecks. Thus, in embodiments of the present invention, eachsub-cache 202(1)-202(N) might form a memory array, and the number ofsystem caches might preferably be implemented as a power of two. One ormore memory blocks might be allocated to each sub-cache 202(1)-202(N).In embodiments of the present invention, each sub-cache 202(1)-202(N)might be implemented as an N-way associative cache employing a leastrecently used (LRU) caching algorithm. In some embodiments, eachsub-cache 202(1)-202(N) might have a total size of 512 kB and a cacheline length of 256 B.

As shown in FIG. 2, one or more of processing modules 204(1)-204(N)might have a corresponding local level one (L1) cache, shown as L1caches 206(1)-206(N). The function of L1 caches 206(1)-206(N) is to actas an interface to system cache 200 for client processing modules204(1)-204(N) of network processor 100. L1 caches 206(1)-206(N) might bereferred to as “pipeline” caches, since L1 caches 206(1)-206(N) mighttypically be employed only for certain ones of client processing modules204(1)-204(N) that access system cache 200 as part of an executionpipeline.

FIG. 3 shows a block diagram of an exemplary embodiment of MTM 300 ofnetwork processor 100, in accordance with embodiments of the presentinvention. In described embodiments, MTM 300 might typically serve as aprocessing node of one or more of the virtual pipelines for taskprocessing in network processor 100. As described herein, a virtualpipeline defines a processing order of a task through one or more of theprocessing modules of network processor 100. Typically, MTM 300 might,for example, serve as a mid-point processing module in a virtualpipeline for unicast packets (e.g., a packet being sent to a singlenetwork node). MTM 300 might also typically serve as a beginningprocessing node of a virtual pipeline for multicast packets (e.g., apacket being sent to multiple network nodes).

As shown in FIG. 3, MTM 300 accesses system memory 210 via an interfaceto switch 100, shown as interface 314, and MTM 300 might interface toone or more clock networks and timer signals of network processor 100via timers and clocks interface 320. MTM 300 includes one or moreinterfaces to various ring communication buses of network processor 100,for example, memory manager interface 316 might interface to the MMB ofnetwork processor 100 via a memory manager ring bus, backpressure ringinterface 318 that might interface to one or more processing modules 204via a backpressure ring bus, configuration ring interface 322 that mightinterface to a configuration manager of network processor 100, and taskring interface 324 which might transfer tasks between one or moreprocessing modules 204 of network processor 100. In general, the one ormore ring buses might function substantially as described in relatedU.S. patent application Ser. No. 12/782,379 filed May 18, 2010, forexample by passing a task from source processing module to a destinationprocessing module. The configuration manager of network processor 100might function substantially as described in related U.S. patentapplication Ser. No. 13/192,140, filed Jul. 27, 2011, for example byconfiguring processing modules of network processor 100 by interfacingwith the configuration ring buses, the system memory, a debugginginterface or internal or external control processors, and ensuringmemory coherency between different memories and caches within networkprocessor 100.

As described herein, network processor 100 might generally send andreceive data packets, for example, an IP packet, and each packet mighthave one or more corresponding tasks sent between processing modules ofnetwork processor 100 for processing of the packet data. As describedherein, MTM 300 schedules data packets corresponding to the tasks fortransmission from network processor 100 according to one or more rules(e.g., priorities, traffic shaping rules, etc.). As shown in FIG. 3, MTM300 includes buffer manager 302, multicaster 304, one or more inputqueues 306, queue engine 308, scheduler 310, control logic and registers312 and one or more L1 caches 313. As will be described, tasks receivedby MTM 300 are placed in one of a plurality of queues, shown as inputqueues 306, until the tasks can be scheduled by scheduler 310 fortransmission by network processor 100. Typical task source processingmodules for MTM 300 include: i) the MPP; ii) the PAB; iii) an errorchecking module of network processor 100, for example a processingmodule that implements a checksum or other error correction for packetsto be transmitted by network processor 100; and iv) one or more controlprocessors of network processor 100 (e.g., one of μP cores 106), forexample when a control packet is inserted in the output stream ofnetwork processor 100. Typical destination processing modules for taskssent by MTM include: i) Stream Editor (SED) since packet data mightrequire editing prior to transmission by network processor 100; ii) theerror checking module of network processor 100, for example if checksumor other error correction data needs to be recalculated for packets tobe transmitted by network processor 100; and iii) one or more controlprocessors of network processor 100 (e.g., one of μP cores 106), forexample when a packet requires additional processing before transmissionby network processor 100.

In some embodiments, input queue block 306 might include four input taskqueues (not shown). Two of the input task queues might be employed toqueue low and high priority unicast packets, and the second pair of taskqueues might be employed to queue low and high priority multicastpackets. This separation of unicast and multicast input queues isbeneficial since multicast tasks typically take longer to enqueue thanunicast tasks, since multiple copies of tasks are placed incorresponding queues for multicast tasks. MTM 300 queues tasks of thesame type in the same task queue in order. MTM 300, via scheduler 310,might implement a programmable weighted round-robin service policybetween the various task queues of input queue block 306. High prioritytask queues might generally be scheduled before low priority taskqueues. In some embodiments, the various queues in block 306 might beimplemented as FIFO queues pointing to task data stored in system memory210. Each FIFO might be implemented as one or more 2 KB blocks that canbe dynamically linked to additional memory blocks, for example such asdescribed in related U.S. patent application Ser. No. 13/046,717, filedMar. 12, 2011. Further, scheduler 310 might typically support up to anN-level scheduling hierarchy. In general, L1 cache 313 might include upto N separate L1 cache modules, one for each hierarchy level ofscheduler 310, where each L1 cache module operates substantially asdescribed in related U.S. patent application Ser. No. 13/192,140, filedJul. 27, 2011. In an exemplary embodiment, N might be 7. Task readmodule 326 might read data corresponding to tasks from system memory 210and interface with task ring interface 324, interface 314 and scheduler310.

FIG. 4 shows an exemplary scheduler and queue hierarchy 400 of MTM 300.As shown in FIG. 4, scheduling hierarchy 400 includes one or more queues406 and one or more schedulers 404, as well as a root scheduler 402.Root scheduler 402 is the first level of scheduling hierarchy 400 andcan schedule either queues 406 or other schedulers 404 since, as shownin FIG. 4, each level of scheduling hierarchy 400 other than the rootlevel can contain either queues 406 or other schedulers 404. Eachscheduler 404 might schedule tasks from a plurality of queues 406 in itslevel. A queue is a leaf node of scheduling hierarchy 400, and mighttypically be a FIFO of tasks corresponding to a packet of networkprocessor 100. A given scheduler 404 might also schedule tasks from oneor more other schedulers in its level. If there are other schedulersunder a given scheduler, there is another level of hierarchy inscheduling tasks. Some embodiments of scheduling hierarchy 400 mightinclude up to seven levels of scheduling hierarchy and allow a maximumof 32 child nodes under root scheduler 402.

Queues might typically exist at any level of scheduling hierarchy 400other than the root level, which might only contain schedulers tosubsequent levels of hierarchy 400. In described embodiments ofscheduling hierarchy 400, any node in the hierarchy might have up to 64k child nodes. Root scheduler 402 and each scheduler 406 in schedulinghierarchy 400 arbitrates between the children of this particularscheduler to pick a task to be scheduled for transmission by MTM 300.Further, root scheduler 402 and each scheduler 406 perform trafficshaping for the particular scheduling node to shape the traffic to aparticular rate. In some embodiments, each scheduler 406 and rootscheduler 402 might selectably perform Smooth Deficit Weighted RoundRobin (SDWRR), Deficit Weighted Round Robin (DWRR) or Strict Priorityarbitration between queues 404 and schedulers 406 under it.

FIG. 5 shows an exemplary task, 500, that might be provided to MTM 300.As shown in FIG. 5, task 500 might typically include one or more taskparameters 501 and task payload 503. As shown, task parameters 501 mightinclude a command type field 502, a Flow ID field 504, a virtualpipeline ID field 506, a shared parameter index field 508, and scriptdata 509. In general, task parameters 501 might include MTM-specificinformation for scheduling the incoming task (e.g., command type field502, flow ID field 504, and virtual pipeline ID field 506). Task payload503 might include task pointers 510 and task data 512. Task pointers 510might point to addresses in system memory 210 storing data correspondingto the task. Task data 512 might include some of the data correspondingto the task (inline data). Command type field 402 identifies the task asa unicast task, an expanded unicast task, or a multicast task.

For a received unicast task, MTM 300 places at most one task in one ofits queues in block 306. For each unicast task, the previous processingmodule in the virtual pipeline for the task (e.g., the one ofaccelerators 108 that provides the task to MTM 300) provides MTM 300with a queue ID for the task to be placed in, for example a queueidentified by flow ID field 504. For unicast tasks, virtual pipeline IDfield 506 might be employed to correct packet length for scheduling of apacket corresponding to the task, for example by adding or subtractingthe number of bytes corresponding to the value of field 506. In someembodiments, shared parameter index field 508 might include a pointerindex to an entry in a shared parameter table of MTM 300 to run scriptdata corresponding to the task.

The shared parameter table might be stored in one or more L1 caches 313of MTM 300. The one or more L1 caches 313 of MTM 300 might operatesubstantially as described in related U.S. patent application Ser. Nos.13/192,104 and 13/192,187, both filed Jul. 27, 2011. The sharedparameter table might include one or more parameters for processing theunicast task, for example, shared parameters can be used to store statedata (for example, statistics of MTM 300 such as packet count or bytecount) based on an input metric (for example, counting all packetsoriginating from a single port destined to a given queue of MTM 300).When MTM 300 receives a unicast task, a template merge operation isperformed on the task that extracts MTM-specific fields from the task(e.g., command type field 502, flow ID field 504, and virtual pipelineID field 506) and determines a queue for the task (e.g., a queue IDvalue from flow ID field 504). Buffer manager 302 also determines if MTM300 can accept the new task for scheduling, for example if the queue ofscheduling hierarchy 400 corresponding to the task is not filled beyonda threshold. If the task is accepted, the task is placed at the tail endof the corresponding MTM queue identified by flow ID field 504. If thetask cannot be accepted by a queue of scheduling hierarchy 400, the taskmight be dropped and removed from the MTM pipeline. The thresholddecision to determine whether a task can or cannot be accepted by agiven queue might be performed by control software running on amicroprocessor of network processor 100.

Expanded unicast tasks are tasks corresponding to unicast packets, butthe task does not contain any a queue ID in flow ID field 504. Thus, thevirtual pipeline down which the expanded unicast tasks were sent withinnetwork processor 100 terminates at MTM 300. MTM 300 determines one ormore destination processing modules or a new virtual pipeline for theexpanded unicast task. Multicast tasks are duplicated by multicaster 304such that the task is stored in multiple queues of MTM 300 to be sent tomultiple destinations. A multicast task includes a flow ID in field 504,which points to a sequence of expanded unicast flow IDs that are usedwhen duplicating the task. Processing of unicast, expanded unicast, andmulticast tasks might be performed by MTM 300 substantially as describedin related U.S. patent application Ser. No. 13/232,422 filed Sep. 14,2011, which is incorporated by reference herein.

Described embodiments might provide a reference count for datacorresponding to a task. The reference count might correspond to anumber of tasks, for example duplicate multicast tasks, that refer tothe data. The reference count might incremented each time a task isduplicated corresponding to a multicast flow. However, in someembodiments, the reference count might not be incremented for eachduplication of the task, but rather is incremented by n−1 for every ncopies of the task. For example, in an exemplary embodiment, thereference count is incremented by 255 for the first duplication of thetask, and is decremented by 256—number of copies for the last copy ofthe task. If there are more than 256 copies, then another increment ismade for every 256th multicast copy.

FIG. 6 shows an exemplary logical flow diagram of task schedulingprocess 600 of MTM 300. As shown in FIG. 6, at step 602, a task isreceived by MTM 300, for example a task such as shown in FIG. 5, whichis received from one of the processing modules of network processor 100via communication ring 118. At step 606, the received task is added tothe tail end of the corresponding queue. Step 606 is described ingreater detail in regard to FIG. 7. At step 608, a top-level parentscheduler (e.g., root scheduler 402 of FIG. 4) of scheduling hierarchy400 selects a child node for scheduling. In some embodiments of thepresent invention, root scheduler 402 might support up to 32 childnodes, all of which are schedulers. At step 608, one of the childschedulers is selected to schedule at least one available task fortransmission by MTM 300. At step 610, if the selected child node is ascheduler, at step 612, the selected scheduler selects one of its childnodes to schedule at least one available task for transmission by MTM300. Steps 610 and 612 might iteratively repeat until a leaf node (e.g.,a queue) of scheduling hierarchy 400 is reached.

At step 610, once a queue is reached in scheduling hierarchy 400, atstep 614, a task from the head of the selected queue is selected, and atstep 616, the selected task is scheduled for transmission by MTM 300.For example, by iteratively selecting, at each scheduling level upscheduling hierarchy 400 from the scheduler that is the direct parent ofthe queue to root scheduler 402, root scheduler 402 selects a task fortransmission by MTM 300. When root scheduler 402 selects a task,corresponding task data might be read from system memory 210, forexample as described in regard to FIG. 16. At step 618, once theselected task is scheduled for transmission, the task is removed fromthe corresponding queue, and one or more statistics of each parent nodecorresponding to the queue might be updated to reflect that the task hasbeen scheduled. The dequeuing operation of step 618 is described ingreater detail with regard to FIG. 9. At step 620, if additional tasksremain in one or more of the queues of MTM 300, scheduling process 600returns to step 608 to select another task for scheduling. If, at step620, no additional tasks remain in one or more of the queues of MTM 300,scheduling process 600 proceeds to step 622, where the schedulingprocess completes until another task is received by MTM 300 at step 602.Although shown in FIG. 6 as being part of scheduling process 600,enqueue operation 606 and dequeue operation 618 might be substantiallyindependent of each other, for example as finite state machines (FSMs)operating on an as-needed basis.

Considering the exemplary scheduling hierarchy shown in FIG. 4, toschedule a task stored in queue 406(3), at step 608, root scheduler 402selects child scheduler 404(1), which corresponds to the scheduled task.At step 610, since the selected child node is a scheduler, at step 612,scheduler 404(1) selects child scheduler 404(3), which corresponds tothe scheduled task. At step 610, since the selected child node is ascheduler, at step 612, scheduler 404(3) selects child scheduler 404(5),which corresponds to the scheduled task. At step 610, since the selectedchild node is a scheduler, at step 612, scheduler 404(5) selects childqueue 406(3), which corresponds to the scheduled task. At step 610,since the selected child node is a queue, at step 614, scheduler 404(5)selects a task from the head of queue 406(3) for transmission by MTM 300at step 616.

FIG. 7 shows an exemplary detail of the enqueue operation of step 606.At step 702, task enqueue operation 606 starts for a given level ofscheduling hierarchy 400. At step 704, MTM 300 retrieves control datacorresponding to the received task from system memory 210. A queue mighttypically be allocated space in one of L1 caches 313 corresponding tothe level of scheduling hierarchy 400 where the queue is located. Atstep 704, one or more data structures for control data corresponding tothe received task read from system memory 210 might be stored in anallocated location of the L1 cache. For example, the L1 caches might beemployed to store one or more data structures for each node ofscheduling hierarchy 400, for example an active task list, a pendingtask list, a task counter, a head pointer and a next pointer of eachscheduler. At step 706, MTM 300 determines a queue of schedulinghierarchy 400 corresponding to the received task, for example, a queueidentified by flow ID field 504 of the received task. In someembodiments, flow ID field 504 might be a 24-bit ID field where an upper4 bits are employed as an index to a scheduler mapping table. Thescheduler mapping table might identify the level at which the incomingtask should be queued. For example, the table might include a pointer tothe corresponding queue. In general, tasks might be grouped togetherinto queues based on certain rules of MTM 300.

At step 708, one or more lists corresponding to the parent scheduler(s)are updated corresponding to the received task. As will be describedsubsequently, lists such as an active task list and a pending task listmight be employed to track the status of each node in schedulinghierarchy 400. At step 708, these lists might be updated to reflect theaddition of the received task to the scheduling hierarchy. At step 710,statistics for each of the at least one parent schedulers are updated,such as the number of tasks under the scheduler, the amount of memoryused, and one or more time values to determine an achieved schedulingrate for the corresponding child node. At step 712, task enqueueoperation 606 ends. In some embodiments of the present invention,enqueue operation 606 might start at the queue level, and proceed upwardthrough the scheduling hierarchy to root scheduler 402.

As indicated by the dashed lines for steps 702, 705 and 710, enqueueoperation 606 might be substantially similar to a re-enqueue operation.As shown in FIG. 7, a re-enqueue operation for a given level ofscheduling hierarchy 400 might start at step 705. A re-enqueue operationmight occur when a scheduler or queue is temporarily removed fromscheduling hierarchy 400, for example as will be described with regardto FIG. 8. A re-enqueue operation replaces the removed node inscheduling hierarchy 400, and the node is again made available for tasksto be scheduled from the corresponding node. As shown in FIG. 7, after are-enqueue operation starts at step 705, at step 706, MTM 300 determinesa queue of scheduling hierarchy 400 corresponding to the re-enqueueoperation. In the case of a re-enqueue operation, a queue ID value mightbe included in the re-enqueue request. At step 708, one or more statuslists corresponding to the parent scheduler(s) are updated correspondingto the re-enqueue operation to reflect the tasks that are added backinto scheduling hierarchy 400. As indicated by the dashed line, step 710might optionally be performed for a re-enqueue operation, since one ormore statistics for each of the at least one parent schedulers might notbe changed due to the re-enqueue operation. At step 712, the re-enqueueoperation ends. In some embodiments of the present invention, there-enqueue operation shown in FIG. 7 might proceed iteratively upwardthrough the scheduling hierarchy from the node level being re-added intothe scheduling hierarchy to root scheduler 402.

FIG. 8 shows an exemplary embodiment of the scheduling operation of step614. At step 802, task scheduling operation 614 starts. At step 804, MTM300 determines an actual packet scheduling rate of the correspondingscheduler and corresponding queue. At step 805, a task from the head ofthe corresponding queue is scheduled for transmission by thecorresponding scheduler, and one or more pointers for the correspondingqueue are updated to reflect a new head entry. At step 806, if theactual packet scheduling rate determined at step 804 is within apredetermined rate restriction for the corresponding scheduler andqueue, then sub-process 614 continues to step 816, where one or moretask control data structures corresponding to the scheduled task areupdated, for example iteratively at each parent scheduler in schedulinghierarchy 400 corresponding to the task. At step 818, task schedulingsub-process 614 completes.

At step 806, if the actual packet scheduling rate determined at step 804is not within a predetermined rate restriction for the correspondingscheduler and queue, then sub-process 614 continues to step 808. One ormore predetermined rate restrictions might be set in a given system. Forexample, certain types of data traffic might be prioritized orde-prioritized, thus queues and/or schedulers corresponding to differenttypes of traffic might have one or more corresponding rate restrictionsto limit maximum packet/data throughput for given traffic types. At step808, the difference between the actual packet scheduling rate determinedat step 804 and the predetermined rate restriction is determined. Thisdifference corresponds to an amount of time that the scheduler or queueshould be removed from the scheduling hierarchy at step 810, such thatqueued tasks can not be scheduled from the given scheduler or queue.After the determined time elapses at step 810, the node exceeding thescheduling rate is re-enqueued in the scheduling hierarchy, for exampleby the re-enqueue operation shown in FIG. 7, and the node is again madeavailable for tasks to be scheduled from the corresponding node. Duringthe amount of time that the given node is removed from schedulinghierarchy 400, tasks might be scheduled from other nodes of thehierarchy, for example by operating as shown in FIG. 8 on another nodeof scheduling hierarchy 400. Sub-process 614 continues from step 810 tostep 816, where one or more task control data structures correspondingto the scheduled task are updated, for example iteratively at eachparent scheduler in scheduling hierarchy 400 corresponding to the task.At step 818, task scheduling sub-process 614 completes.

When a task is available for scheduling at the top of schedulinghierarchy 400, the scheduler at the top level (e.g., root scheduler 402)schedules the task for transmission. As shown in FIG. 6, upon schedulingthe task for transmission, MTM 300 might initiate a dequeue operation toremove the scheduled task from its corresponding queue in schedulinghierarchy 400, for example at step 618. FIG. 9 shows an exemplary flowdiagram for dequeue sub-process 618. Dequeue process 618 starts at step902. At step 904, the parent scheduler sends a message to a child nodecorresponding to the task indicating that the task has been scheduledfor transmission, as will be described in greater detail subsequently.At step 906, the selected child node responds to the parent scheduler,for example with a value by which to update the parent task counter atstep 908. At step 910, if the child node is a queue, it corresponds tothe lowest level of that branch of scheduling hierarchy 400 (e.g.,queues are leaf nodes; as shown in FIG. 4, exemplary queues406(1)-406(9) are each the last node in their respective branches ofscheduling hierarchy 400). If the child node is a queue, and, thus, thelowest level of the scheduling hierarchy, at step 912, the number ofpackets to be scheduled for transmission corresponding to the task isdetermined and provided to each scheduler corresponding to the queue. Atstep 914 the scheduled task is removed from the corresponding queue. Atstep 916, dequeue sub-process 618 completes. If, at step 910, the childnode is not a queue, the child node is a scheduler, and dequeuesub-process 618 returns to step 904 to process the parent-child messagesfor this subsequent level of scheduling hierarchy 400. Steps 904 through910 might iteratively repeat until, at step 910, the child node is aleaf node (e.g., the queue corresponding to the task). Each parent-childcommunication cycle is a “scheduling cycle” of MTM 300. As indicated bydashed line 918, a scheduling cycle is completed when the child noderesponds to the top level scheduler. Thus, for a given task, multiplescheduling cycles might be required to perform a dequeue operation toremove a scheduled task from a corresponding queue of the schedulerdepending on the number of schedulers between the top level scheduler(e.g., root scheduler 402) and the corresponding queue. In someembodiments of the present invention, dequeue operation 618 might startat root scheduler 402 and proceed downward through the schedulinghierarchy to the queue level.

Considering the exemplary scheduling hierarchy shown in FIG. 4, if atask from queue 406(3) is scheduled for transmission by MTM 300 ofcorresponding packets, at step 618, the scheduled task is dequeued fromqueue 406(3). The highest level scheduler in scheduling hierarchy 400 isroot scheduler 402. At step 904, root scheduler 402 sends a message toits child scheduler 404(1), which corresponds to the scheduled task. Atstep 906, scheduler 404(1) responds to root scheduler 402, and at step908, root scheduler 402 updates its corresponding task counter, ending afirst scheduling cycle. At step 910, since scheduler 404(1) is not aqueue, process 618 returns to step 904. At step 904, scheduler 404(1)sends a message to its child scheduler 404(3), which corresponds to thescheduled task. At step 908, scheduler 404(3) responds to scheduler404(1), and at step 908, scheduler 404(1) updates its task counter,ending a second scheduling cycle. Again, at step 910, since scheduler404(3) is not a queue, process 618 returns to step 904. At step 904,scheduler 404(3) sends a message to its child scheduler 404(5), whichcorresponds to the scheduled task. At step 908, scheduler 404(5)responds to the message from scheduler 404(3), and at step 908,scheduler 404(3) updates its corresponding task counter, ending a thirdscheduling cycle. Again, at step 910, since scheduler 404(5) is not aqueue, process 618 returns to step 904. At step 904, scheduler 404(5)sends a message to its child queue 406(3), which corresponds to thescheduled task. At step 906, queue 406(3) responds to the message fromscheduler 404(5), and at step 908, scheduler 404(5) updates itscorresponding task counter, ending a fourth scheduling cycle. At step910, since queue 406(3) is reached, at step 912, the number of packetsto be scheduled for transmission corresponding to the task aredetermined and provided to schedulers 404(1), 404(3), 404(5) and rootscheduler 402. At step 914 queue 406(3) removes the scheduled task fromits linked list, for example by updating one or more pointerscorresponding to queue 406(3) in schedulers 404(1), 404(3), 404(5) androot scheduler 402. At step 916, dequeue sub-process 618 completes.

Thus, as described herein, MTM 300 might perform an enqueue operation(FIG. 7) or a re-enqueue operation (step 812 of FIG. 8) to add a task toscheduling hierarchy 400. The enqueue operation is performed when a taskarrives at the input of MTM 300. The re-enqueue operation is performedwhen a node of scheduling hierarchy 400 satisfies scheduling rateshaping constraints and tasks of the node can be made available fortransmission by MTM 300. MTM 300 might perform a dequeue operation (FIG.9) to remove a task from scheduling hierarchy 400. The dequeue operationis performed when a scheduler has tasks scheduled for transmission byMTM 300.

Described embodiments of MTM 300 might speculatively schedule, in asuperscalar manner, more than one task in a clock cycle to achieve ascheduling rate higher than when scheduling a single task in the clockcycle. As described herein, embodiments of the present invention employa scheduling hierarchy that is a tree structure of schedulers andqueues. As described, each scheduler might have zero or more childschedulers 404 or queues 406, where schedulers are branch nodes andqueues are leaf nodes of scheduler tree 400. Each queue 406 mightcomprise a linked list of tasks being processed by network processor100. As described, when a task is received by MTM 300, the task is addedto the tail end of a corresponding queue, and one or more parentschedulers corresponding to that queue are updated throughout the treestructure corresponding to the newly arrived task.

Described embodiments thus might increase the throughput of eachscheduler in the scheduling hierarchy by scheduling multiple tasks ineach scheduling cycle. Some embodiments might allow a parent schedulerto schedule multiple tasks from a child node (which can be either ascheduler or a queue) in each scheduling cycle. The child node respondsto the parent scheduler indicating whether the scheduling of the taskshas been accepted, and if so, how many tasks are accepted. The number ofscheduled tasks propagates through the scheduling hierarchy from thequeue through its parent scheduler up to the root scheduler at the topof the scheduler hierarchy. Data structures are maintained at eachscheduler and queue, and might be updated to reflect the updated taskcounter.

Referring to FIG. 7, during task enqueue operation 606, the queuestructure is updated with the new task(s) being added to its tail atstep 708. At step 710, statistics at the queue are updated to reflectthe new task counts and memory usage for corresponding task data. Theparent scheduler is informed of the new task(s) through updatedstatistics (step 710) such as the task count. Steps 708 and 710 arerepeated at each of the higher levels of scheduling hierarchy 400 untilroot scheduler 402 is updated. Re-enqueue operations are similar, buttypically start at the level of scheduling hierarchy 400 containing thenode satisfying the constraints and being made available for scheduling.

A task dequeue operation, such as shown in FIG. 9, occurs after thecorresponding scheduler schedules one or more tasks from one of itschild nodes (e.g., at step 614). As described herein, each schedulermight employ a selected arbitration algorithm to select the child fromwhich tasks are scheduled and sends a message to the child node (ascheduler or a queue) indicating that a task is scheduled for that child(e.g., at step 904). The child responds to the schedule messageindicating whether the child accepted the schedule (e.g., at step 906).Based on the child's response, the parent scheduler updates its owncorresponding task count for that child (e.g., at step 908). In someinstances, step 908 might also include the parent scheduler waiting apredetermined amount of time before scheduling the task, for example tomaintain a desired traffic shaping rate. During this wait time, theparent scheduler might begin execution on a new task schedule operationhanded down by its parent. Thus, each scheduler of scheduling hierarchy400 is multithreaded to increase the throughput of scheduling packets byMTM 300. Further, each scheduling level might simultaneously work on adifferent scheduling task affecting different nodes of schedulinghierarchy 400 due to the pipelined nature of the scheduling process(e.g., as shown in FIGS. 6-9).

After step 908, a scheduling cycle is complete and the parent schedulercan begin a new scheduling cycle (e.g., at step 904). Also, on receivinga schedule message from the parent (e.g., at step 904), the child nodestarts its own scheduling cycle to communicate to its own child nodecorresponding to the scheduled task(s) (e.g., at step 904). Once a queueis reached as the child node (e.g., at step 910), characteristics aboutthe data corresponding to the scheduled task, the data flow, and thedestination receiver are determined (e.g., at step 912). For example,the queue might determine the actual amount of data corresponding to thescheduled task(s), the number of tasks that can be scheduled, and mightindicate a desired data rate of the data flow and destination receiver.The corrected number of tasks to be scheduled is propagated throughscheduling hierarchy 400 to update the number of tasks available forscheduling at each node.

Described embodiments provide a method of implementing byte accuratescheduling of tasks from a queue when the size of a packet correspondingto the task (e.g., the amount of data to be transmitted by MTM 300) isnot known at the time of scheduling. Task scheduling rules such asshaping rates and arbitration rules are applied at each level of thehierarchy, and preferably these rules are applied in a byte accuratefashion. As described herein, queues are collections of tasks waiting tobe scheduled at a specific rate and schedulers are any combination ofqueues and other schedulers. Described embodiments typically schedulequeues or schedulers using a “default packet size” and then correct thevarious scheduler algorithms using a “task update” when the actual sizeof the packet being scheduled is known. The actual packet size might begreater than or less than the default packet size, and the task updatemight indicate the difference between the default packet size and theactual packet size.

When the scheduler runs, the default packet size might be used toperform traffic shaping and arbitration. In some embodiments, trafficshaping might be based on a desired data rate for traffic of a givenqueue or scheduler, and arbitration might be based on a Deficit WeightedRound Robin (DWRR) or a Smooth Deficit Weighted Round Robin (SDWRR),described subsequently. The scheduling proceeds down the schedulinghierarchy from the root scheduler to a chosen queue. Once a task ischosen from a queue, the data packet corresponding to the task is readfrom system memory 210, and the queue sends a task update message toeach scheduler up to the root scheduler indicating the actual size ofthe packet data corresponding to the task. When the task update messageis received by a scheduler, each scheduler updates its traffic shapingcontrol data (e.g., leaky token buckets) and arbitration control data(e.g., DWRR buckets) to account for the difference between the defaultpacket size and the actual packet size, for example at step 816 of taskscheduling sub-process 614 of FIG. 8. The task update message mightinclude two packet size correction fields, one to be applicable for ascheduler and one to be applicable for the task. For example, the firstpacket size correction field might be employed for updating the packetsize at each scheduler, and the second packet size correction fieldmight be employed to indicate that the packet corresponds to a dataprotocol that might change the packet size downstream from MTM 300, butbefore transmission by network processor 100 (e.g., by adding achecksum, encryption, or at other protocol layers, etc.).

In some embodiments, the default packet size might be set by controlsoftware running on a processor of network processor 100. Each schedulerincludes an associated default packet data size value. The defaultpacket data size might be employed to perform speculative readoperations, as described subsequently. In embodiments of the presentinvention, the default packet data size value is defined for eachscheduler as an integer multiple of 16 byte increments (e.g., N*16 B),where N is the default packet scale value of the scheduler. Further, thevalue of N might be set by control software of network processor 100.

As described herein, one or more schedulers within scheduling hierarchy400 might employ a smooth deficit weighted round robin (SDWRR)arbitration algorithm. In some embodiments, SDWRR arbitration might beemployed by root scheduler 402 to perform fast scheduling of tasksavailable at its children schedulers. Since root scheduler 402 schedulesevery task within MTM 300, root scheduler 402 beneficially scheduleseach task from a child as fast possible, and moves on to the next childthat has tasks available for scheduling. To reduce the time required toschedule each task, root scheduler 402 beneficially employs relativelysmall data structures and little control logic to issue up to one newschedule every cycle.

FIG. 10 shows an exemplary flow diagram of SDWRR arbitration routine1000 of root scheduler 402. At step 1002, SDWRR arbitration routinestarts, for example at startup of MTM 300. At step 1004, root scheduler402 checks the status of one or more indicators of a first childscheduler (e.g., a first one of level-one schedulers 404(1) and 404(2)from example scheduling hierarchy 400 of FIG. 4). In some embodiments,each scheduler in scheduling hierarchy 400 might be assigned a schedulerID value, and root scheduler 402 might typically support a fixed number,N, of level-one schedulers. In some embodiments, N is 32. In suchembodiments, each of the 32 level-one schedulers might employ contiguousID values such that level-one schedulers have ID values from a basescheduler ID value up to the base scheduler ID value+31. A statusindicator for the level-one child schedulers might include one or moreindicators that root scheduler 402 employs to determine a current statusof each level-one scheduler. For example, status indicators mightinclude one or more N-bit vectors, where each bit in each N-bit vectorcorresponds to a given level-one scheduler. For example, a first bitvector might indicate that a level-one scheduler is active, a second bitvector might indicate that a level-one scheduler is backlogged, and athird bit vector might indicate that a response to root scheduler 402from the child scheduler is pending. An active scheduler is one havingone or more tasks queued for scheduling. A pending scheduler is one thatroot scheduler 402 has scheduled, but has not yet responded to rootscheduler 402. A backlogged scheduler is one that has exceeded itsarbitration scheduling limit (e.g., the data rate for the correspondingdata has reached its traffic shaping limit). Each child queue andscheduler has a corresponding arbitration scheduling limit.

At step 1006, root scheduler 402 determines whether the selectedscheduler ID value is an active scheduler, for example by checking theactive bit vector value corresponding to the selected scheduler. In someembodiments, root scheduler 402 might start at the lowest scheduler IDvalue and increment the value, proceeding upward to the highestscheduler ID value before returning to the lowest scheduler ID value,and so on, although other implementations are possible. At step 1006, ifthe selected child scheduler is inactive, SDWRR algorithm 1000 proceedsto step 1020, where the next scheduler is selected, and processingreturns to step 1004 to check the status of the newly selectedscheduler. At step 1006, if the selected child scheduler is active,SDWRR algorithm 1000 proceeds to step 1008.

At step 1008, if the child scheduler has been scheduled, but a responsehas not yet been sent to root scheduler 402, then the child scheduler ispending, and SDWRR algorithm 1000 proceeds to step 1014. At step 1014,root scheduler 402 waits for an acknowledgement signal from the childscheduler before processing the corresponding child scheduler. In someembodiments, root scheduler 402 might process other active childrenwhile waiting for a response from the corresponding child scheduler. Atstep 1018 the one or more status indicators corresponding to theselected scheduler are updated. If, at step 1008, the child scheduler isactive, but no response is pending to root scheduler 402, then SDWRRalgorithm 1000 proceeds to step 1010. At step 1010, if the selectedchild scheduler is backlogged, at step 1016, the selected schedulermight be moved to the tail end of the active scheduler list such thatother child schedulers are selected before the backlogged scheduler isselected again. Alternatively, the selected scheduler might be moved offthe active list and placed on a backlogged list. If, at step 1010, theselected child scheduler is not backlogged, at step 1012, one or moretasks from the selected child scheduler are scheduled for transmissionby MTM 300. In general, root scheduler 402 might select one or moretasks from the child scheduler at the head of the active list.

Once a task is scheduled from a child scheduler at step 1012, at step1018 the one or more status indicators corresponding to the selectedscheduler are updated. For example, the selected child scheduler mightremain in the active list (if it has not reached its correspondingarbitration limit and, thus, is not backlogged), or the selected childscheduler might be moved to the pending list (if a response to thescheduling of step 1012 is not yet received from the selected childscheduler), or the selected child scheduler might be added to abacklogged list (if the selected child scheduler is backlogged). In someembodiments, the pending list and backlogged list might be implementedas one list. When the child scheduler is added to the pending list, itsarbitration limit might be restored, and the child scheduler is addedback to the active list once it is below its corresponding shaping rateand it has tasks available for scheduling. If the active list becomesempty, the pending list might become active before the shaping rate isreached. If a child scheduler becomes empty, having no tasks left toschedule, the child scheduler ID value might be provided to timer andclock interface 320 for further processing. Once the status indicatorsare updated, SDWRR algorithm 1000 proceeds to step 1020, where the nextscheduler is selected, and processing returns to step 1004 to check thestatus of the newly selected scheduler.

In an exemplary embodiment, root scheduler 402 might employ a 5-bitpointer indicating the next child scheduler to be selected from up to 32child schedulers. To select a new child for scheduling, root scheduler402 might search through the status bit vectors from the pointer valueto the highest scheduler ID value to look for a next scheduler ID valuehaving its corresponding active indicator set without having acorresponding pending indicator or backlogged indicator set (e.g., atsteps 1004, 1006, 1008 and 1010). Upon scheduling a scheduler (e.g., atstep 1012), the pointer value is updated to the next contiguousscheduler ID value from the selected scheduler (e.g., at step 1018). Ifno scheduler ID value between the pointer value and the highestscheduler ID value can be scheduled, then child schedulers having IDvalues between the lowest scheduler ID value and the pointer value canbe selected for scheduling (e.g., at step 1012). This technique providessmoothness of the arbiter by providing every child scheduler with achance to be scheduled before the same child scheduler can be picked forconsecutive scheduling cycles.

At step 1012, root scheduler 402 sends a scheduling event to theselected scheduler (e.g., the scheduler having an ID value equal to baseS1 scheduler ID+selected scheduler offset). The selected child schedulersends a response to root scheduler 402 (e.g., at step 1014). In theresponse, the selected child scheduler might indicate that the childscheduler should become (1) backlogged and inactive (e.g., the childscheduler has reached its traffic shaping rate), (2) should becomeinactive and be removed from scheduling hierarchy 400 (e.g., the childscheduler has become empty), or (3) that the child scheduler shouldremain active (e.g., the child scheduler has not yet reached its trafficshaping rate and is not backlogged). Thus, SDWRR algorithm 1000 isweighted, in that each child scheduler indicates in its response whetherit needs to be taken out of the arbitration due to constraints such asthe shaping rate for that child, etc. Steps 1004, 1006, 1008, 1010, 1012and 1018 might typically be performed in a single scheduling cycle ofMTM 300, thereby achieving a fast scheduling rate compared to otherSDWRR implementations requiring multiple tens or hundreds of cycles foreach schedule operation.

Described embodiments track the number of tasks to be scheduled by eachnode in scheduling hierarchy 400 by localized message passing and acapped task count. Each node of scheduling hierarchy 400 reports“capped” task count value to its parent scheduler. Each node mightemploy a “parent view” data structure to track the task count previouslyreported to the parent scheduler. Each node of scheduling hierarchy 400beneficially tracks how many tasks are under it, so scheduling occursfor each task. Since a given node might have several child nodes underit in its subtree of scheduling hierarchy 400, the number of tasks undera given parent node might be very large (several millions). Thus,maintaining an absolute packet count at every node of schedulinghierarchy 400 could require very large counters. Also, described enqueue(e.g., FIG. 7) and dequeue (e.g., FIG. 9) processes are not necessarilyinstantaneous, and task counts are desirably updated accurately.Described embodiments beneficially limit the size of task counters ateach scheduling level by limiting the task count size, and account forpotentially simultaneous enqueue and dequeue operations along a branchin scheduling hierarchy 400.

Each queue in scheduling hierarchy 400 might maintain an absolute taskcount. Each child node in scheduling hierarchy 400 communicates a“capped” task count to its corresponding parent scheduler. The “capped”task count might be equal to the task count of the child node, but mightbe limited to no greater than a fixed value. In some embodiments, thefixed value is 15, such that if the task count is less than or equal to15, then the capped task count is equal to the actual number of tasks,otherwise, the task count is set to a maximum value of 15. Task countsare transferred between child nodes and parent nodes by localizedhandshake messages such that the task count is only transferred from achild to parent. Task count data is transferred from the bottom level ofscheduling hierarchy 400 to the top of scheduling hierarchy 400 by localexchange of messages, one level at a time.

Each node of scheduling hierarchy 400 maintains a “parent view” datafield. The parent view field specifies the task count of the child nodefrom the parent scheduler's point of view (e.g., the task count reportedby the child to the parent scheduler). The parent view task count mightdiffer from the actual task count for one of several reasons: (i) thetask count of the child node is capped at the maximum reported taskcount, (ii) the task count of the child node is below the capped valuebut the task count of the child node changed after the last handshakemessage to its parent scheduler, or (iii) the child node is beingremoved from scheduling hierarchy 400, for example, for traffic shaping.

During task enqueue operations (e.g., FIG. 7), each child node sends amessage to its parent scheduler to increment the task count (e.g., atstep 710) if the task count is below the capped value. If the task countexceeds the capped value, the task count of the parent scheduler is notincremented. As described herein, task enqueue operations start at thequeue level and proceed up scheduling hierarchy 400 to root scheduler402. The task count is updated as described at each level of schedulinghierarchy 400. Re-enqueue operations might be substantially similar, butmight start at any corresponding level of scheduling hierarchy 400 andmight increment the task count by a value greater than 1.

During task dequeue operations (e.g., FIG. 9), the process starts at thetop of scheduling hierarchy 400 at root scheduler 402. When a parentschedules a child node, the parent sends a message to the child node(e.g., at step 904), and the child node responds (e.g., at step 906) tothe parent indicating an amount to increment or decrement the parent'stask count (e.g., at step 908). The child node determines this value bycomparing its “parent view” data field to its task count value, and thenumber of tasks to be scheduled. As will be described, a child mightschedule one or more tasks in a cycle. In one embodiment, a child mightschedule 0, 1 or 2 tasks per scheduling cycle. Additionally, a childmight remove itself from its parent, for example due to traffic shapingrequirements, in which case, the child node decrements the parent taskcount by the parent view value (e.g., reports a task count of 0 since notasks are eligible for scheduling).

Employing a capped task count at each parent scheduler level allows thecounters at the parent levels to be bounded to known, relatively smallvalues (and thus, an arbitrarily large counter is not required tosupport the several millions of tasks that could potentially be in agiven scheduling branch). Further, local parent-child messaging todetermine task counts at each level of scheduling hierarchy 400beneficially de-centralizes the tracking of task counts. Employing theparent view data field allows updating the parent with a new task countvalue even if the corresponding scheduling operations are not complete.

Each scheduler in scheduling hierarchy 400 is a configurable arbiter andrate enforcer for tasks assigned to queues and child schedulers from onelevel to the next higher level of scheduling hierarchy 400. To achievedesired scheduling rates for multiple different traffic flows,scheduling hierarchy 400 might provide for up to N scheduling levels ofqueues and schedulers below root scheduler 402. In some embodiments, Nis 6 levels for scheduling hierarchy 400. Each level in schedulerhierarchy 400 might have substantially similar characteristics (e.g.,each scheduler 404 might operate substantially similarly and each queuenode 406 might operate substantially similarly), while root scheduler402 operates as a special case as described, for example, with regard toFIG. 10. In embodiments employing 6 scheduling levels, level 0 is thetop scheduling level and generally has only one scheduler, rootscheduler 402. In some embodiments, level 1 might have only schedulers(no queues), and levels 2 to 5 might have any number of queues andschedulers up to a predefined maximum number of child nodes under asingle parent scheduler, which in some embodiments is a maximum of 64 kchild nodes. Level 6 might only have queues, since it is the lowestlevel of scheduling hierarchy 400.

As described herein, scheduling hierarchy 400 is a tree structure ofschedulers at higher levels and queues as leaf nodes. A queue is astructure with a list of tasks that serves as an entry point for tasksinto the scheduling hierarchy. A queue might exist at any level of thescheduling hierarchy, although in some embodiments, only schedulersmight be children of root scheduler 402. In described embodiments,scheduling hierarchy 400 might be implemented as any hierarchicalconfiguration (symmetric or asymmetric), up to hardware defined maximumlevel of schedulers, through static configuration and dynamicconfiguration updates during operation of network processor 100.

In described embodiments, queues might be added under any level ofscheduling hierarchy 400 other than root scheduler 402, and the totalnumber of queues in scheduling hierarchy 400 might be unlimited forpractical purposes (e.g., several millions of queues), limited only bythe maximum value of the queue ID value, and the size of system memory210 for storing data corresponding to queued tasks. Queues might bedynamically added or deleted in scheduling hierarchy 400 duringoperation of network processor 100 by adding or removing a queue IDvalue from the active, pending and backlogged status indicators of thecorresponding one or more parent schedulers. As described herein,schedulers might be added at any level of scheduling hierarchy 400 andconsist of queues and schedulers under it. The number of schedulerssupported by scheduling hierarchy 400 might also be relatively large(e.g., several millions). In some embodiments, each scheduler node mightsupport a maximum of 64 k children queues and schedulers. Each level inthe scheduling node performs two functions: (i) arbitrating between thechildren of this particular node to pick a winner for scheduling, and(ii) traffic shaping the particular node to a particular data rate.These functions might be performed by hardware logic circuits, or mightbe performed under software control using a traffic shaper script of MTM300.

One or more configurable mapping tables are employed to map a receivedtask to a flow ID to a given queue of scheduling hierarchy 400. The oneor more configurable mapping tables might be dynamically created andupdated during operation of network processor 100. During operation ofnetwork processor 100, scheduling hierarchy 400 might be populated withone or more schedulers and queues to receive incoming tasks. The amountof data stored in system memory 210 corresponding to tasks queued inscheduling hierarchy 400 changes during operation corresponding to theincoming and transmitted tasks. Scheduling hierarchy 400 might bemodified dynamically during the runtime, for example, by draining aparticular branch of scheduling hierarchy 400, or by adding a branch ofone or more schedulers and queues to scheduling hierarchy 400. Indescribed embodiments, the queue and scheduler data structures might be64-byte data structures stored in system memory 210 to align with theline sizes of the memory and caching data structures. Queue Engine 308performs the maintenance of the data structures of scheduling hierarchy400 in system memory 210.

Each data flow has an associated ID value. In an exemplary embodiment,the flow ID is a 24-bit value where the upper 4 bits index into a levelmapping table of MTM 300. The level mapping table defines the level ofscheduling hierarchy 400 where the data flow should be queued, andincludes a parent ID value, which is a pointer to a location in systemmemory 210 storing the data structure for the parent scheduler for theflow ID. The parent ID value and the lower 20-bits of the flow ID valuedetermine the physical memory address of the corresponding schedulerdata structure. Thus, the scheduling hierarchy allows for arbitraryconfiguration of queues, in terms of the number of queues at a givenlevel of scheduling hierarchy 400, and the level of scheduling hierarchy400 of the parent scheduler of the queue. In addition to hierarchyinformation, the scheduler data structures might also contain trafficshaping data such as constraints on the maximum peak and sustained datarates allowed for the particular node. The structures might also storestate data, such as a time value for the last task transmission and anamount of system memory 210 used to store task data, for use in decidingwhen the node should be allowed for scheduling a next time.

For fully populated levels of hierarchy, a new queue might typically beinserted to the scheduling hierarchy at the lowest level (e.g., level 6,as shown in the exemplary hierarchy of FIG. 4). If the queue structureindicates that the parent scheduler is at a higher level (e.g., a level3 scheduler such as scheduler 404(5) instead of a level 5 scheduler suchas scheduler 404(10)), the queue fetch logic ignores the absentintermediate scheduler levels, for example during scheduling, enqueueand dequeue operations. Each of the levels of scheduling hierarchy mighthave one or more corresponding mapping tables in Queue Engine (QE) 308.By updating the one or more mapping tables of the scheduling hierarchy,MTM 300 might dynamically update the structure of scheduling hierarchy400, for example by moving a scheduling node up or down in thehierarchy, adding a branch to the hierarchy, inserting new queues, orremoving nodes with no queued tasks. Further, to modify the schedulinghierarchy, task data is not moved, rather unused schedulers are bypassedto move a queue to a higher scheduling level. Thus, the level inscheduling hierarchy 400 of the parent scheduler of a queue might beconfigured by a control processor of the network processor to achieve acertain desired scheduling rate.

In described embodiments, each scheduler other than root scheduler 402might selectably employ any arbitration algorithm, for example a SmoothDeficit Weighted Round Robin (SDWRR) such as shown in FIG. 10, a DeficitWeighted Round Robin (DWRR) or strict priority arbitration between thequeues and schedulers under it. For embodiments where schedulers otherthan root scheduler 402 employ SDWRR arbitration, some embodiments mightemploy two linked lists: one for active, and one for backlogged, childnodes. The child node at the head of the active list is selected forscheduling. If the child has exceeded the corresponding SDWRRarbitration limit, but is backlogged, the child is sent to the tail ofthe pending list. If the child has not exceeded the corresponding SDWRRarbitration limit (and is backlogged), the child is sent to the tail ofthe active list. If the child is no longer backlogged (either becausethe child is empty, or the child has exceeded its shaping limit), thechild node is removed from both the active list and the backlogged list.

FIG. 11 shows a flow diagram of an exemplary DWRR scheduling algorithm.In DWRR mode, each scheduling node has a logical linked list of childrenunder it. Each child has a DWRR limit associated with it. The schedulingnode picks the head of the list as the winner each time. The node at thehead of the list stays at the head until is has used up its DWRR limitor the node is either above its shaping rate or is empty. At step 1102,DWRR scheduling algorithm 1100 starts. At step 1104, the parentscheduler selects the child node at the head of the linked list forscheduling. At step 1106, the scheduled task counter is incremented forthe selected child, and the incremented value is compared to the DWRRarbitration limit associated with the selected child. If, at step 1108,the incremented value has reached or exceeded the DWRR arbitrationlimit, then algorithm 1100 continues to step 1110, where the selectedchild node is moved to the tail end of the linked list, and the nextchild node in line becomes the head node. Processing then returns tostep 1104, where the parent scheduler selects the child node at the headof the linked list for scheduling. At step 1108, if the incrementedvalue has not reached or exceeded the DWRR arbitration limit, thenalgorithm 1100 returns to step 1104, where the parent scheduler selectsthe child node at the head of the linked list for scheduling.

FIG. 12 shows a flow diagram of an exemplary strict priority schedulingalgorithm. In strict priority mode, each scheduling node might have apredetermined maximum number, M, of child nodes. In some embodiments, Mmight be equal to a maximum of four children. At step 1202, strictpriority scheduling algorithm 1200 starts. At step 1204, the parentscheduler assigns each child node a priority value zero through M−1(e.g., 0-3). At step 1206, the child with the highest priority with oneor more tasks available for scheduling is chosen. At step 1208, if thehighest priority child node becomes empty, at step 1210, the nexthighest priority child node with one or more tasks available forscheduling is chosen, and that child node is scheduled at step 1206. If,at step 1208, the highest priority child node is not empty, at step1212, a test determines if the child node has reached a predetermined“starvation avoidance limit”, and, if so, at step 1214 a predeterminednumber of tasks might be scheduled from a given lower priority childnode, even though the higher priority child node was non-empty. Thismechanism prevents one higher priority child node from completelystarving scheduling of tasks from a lower priority child node. If, atstep 1212, the test determines that the child node has not reached thepredetermined starvation avoidance limit, strict priority schedulingalgorithm 1200 returns to step 1206 to schedule tasks from the highestpriority child node. In some embodiments, the starvation avoidance limitmight selectively be turned on or off for a given node of schedulinghierarchy 400 by control software running on a processor of networkprocessor 100.

In embodiments of the present invention, traffic shaping rates mightselectably employ either a peak/sustained mode or a peak/minimum mode toenforce task scheduling traffic shaping of nodes of scheduling hierarchy400. In the peak/sustained mode, each node might be assigned acorresponding peak rate and a corresponding sustained rate. Inpeak/minimum mode, each node might be assigned a corresponding peak rateand a corresponding minimum rate. In peak/sustained mode, if a trafficshaper of MTM 300 determines that a given node is scheduling tasks toofast, the traffic shaper might disallow the node from scheduling moretasks (e.g., by removing the child node from the corresponding parent'slist for a predetermined time). In peak/minimum mode, if a given childnode is scheduling tasks over the peak rate, the child node might bedelayed from scheduling tasks for a predetermined amount of time. Aseparate calculation is performed based on the child's minimum rate thatmight allocate additional arbitration credits to the child at the rateof its minimum rate, such that the child is allowed to schedule taskswithout going below a minimum rate.

Described embodiments provide a minimum rate guarantee for a node inscheduling hierarchy 400 employing a byte-based token bucket. Whenemploying SDWRR or DWRR arbitration, the bandwidth available from theparent is distributed in the ratio of each child node's arbitrationbucket weights. To guarantee a minimum rate at each child node, anamount of bandwidth might be reserved and then the remaining bandwidthmight be distributed in the ratio of the bucket weights. The minimumrate guarantee for a given child node might be implemented byincrementing the child's arbitration token bucket by a determined amountat a rate corresponding to the guaranteed minimum rate. The amount thatis added to the child's token bucket is determined by the computation:(time elapsed from last transmission)*desired minimum rate (expressed inbytes per time). By applying the compensation in bytes, the algorithm isindependent of packet size that is being transmitted by networkprocessor 100 corresponding to the various scheduled tasks to transmitwhole packets that might be of arbitrary size.

Described embodiments account for differences in the scale of time andrate between the minimum rate and other rates implemented for the child,since the minimum rate might be much smaller than the child's peak rate.To account for varying rates, a credit to the arbitration bucket isperformed in units of bytes and 8 bits of a byte fraction. In describedembodiments, MTM 300 might typically support a 64 b time value that isavailable from a timer or clock of network processor 100 via timer andclock interface 320. Each increment of the clock might be called a“clock tick”. In some embodiments, a 24 b subset (“scaled clock”) of the64 b time value might be selected to calculate timing for a given nodeof scheduling hierarchy 400. Which 24 b subsets are chosen is based on ascaling factor corresponding to the node, which might be set by controlsoftware of network processor 100. Each scheduling node might maintain a“last transmit time” value corresponding to a time value when the nodewas most recently scheduled by its parent scheduler.

To account for large variations between the minimum rate and the actualrate, some embodiments might also include an additional minimum ratescaling factor (8 b field) that might be employed to further scale timevalues used for minimum rate calculations. The desired guaranteedminimum rate might be set by control software of network processor 100as a 16-bit field. For example, the 16-bit desired minimum rate valuemight correspond to the number of bytes that should be transmitted in256 scaled time ticks, where the scaled time ticks is the elapsed timescaled according to the node's scaling factor and the additional minimumrate scaling factor.

FIG. 13 shows exemplary minimum rate scaling method 1300. Minimum ratescaling method 1300 starts at step 1302. At step 1304, the elapsed time(“delta time”) between the last time value a task was scheduled from thenode, and a current time value is determined by the scheduler. At step1306, the determined elapsed time is scaled by the scaling factor (e.g.,which 24 bits of the 64-bit clock value are chosen). At step 1308, ifthe child node employs the additional minimum rate scaling factor, thenmethod 1300 proceeds to step 1310, where the additional minimum ratescaling factor is added to the scaled elapsed time value, and thenmethod 1300 proceeds to step 1312. At step 1308, if the child node doesnot employ the additional minimum rate scaling factor, then method 1300proceeds to step 1312. At step 1312, the credit value, in bytes andfractions of bytes, is determined that must be added to the child node'sarbitration bucket value. At step 1314, the determined credit value isadded to the child node's arbitration bucket. At step 1316, method 1300ends.

In an exemplary embodiment, at steps 1304 and 1306, the elapsed time(delta time) is determined by the calculation: PCR deltatime[31:0]=current timestamp[31:0]−last transmit time[31:0]. Thiscalculates delta time in peak cell rate (PCR) time units. At steps 1310and 1312, the credit value is determined by shifting the determineddelta time by the minimum rate scaling factor: MCR delta time[23:0]=(PCR delta time>>min rate scaling factor)[23:0]+additionalminimum rate delta time[7:0]. The additional minimum rate delta timevalue was stored based on a previous calculation (e.g., steps 1306 and1310). This step shifts delta time to minimum cell rate (MCR) timeunits. Additionally, bucket value[31:0]=old bucket value[31:0]+(MCRdelta time[23:8]*desired minimum rate[15:0])[31:0]. This step computesthe arbitration bucket value in terms of bytes plus 8 bits of fraction.The fraction (lower 8 bits of the bucket value) and delta time fraction(lower 8 bits of the MCR delta time value) are stored in memory to usefor a subsequent repetition of process 1300. The minimum rate (min rate)that is programmed is the number of bytes that can be transmitted in 256scaled time units, where a scaled time unit is based on a minimum ratetime scale.

Thus, described embodiments provide a method to guarantee a minimum ratefor nodes in an arbitration mechanism of a packet-based network. Sincethe “credit” is calculated in bytes and added to a byte based tokenbucket, the scheduling node might still schedule a whole number ofpackets.

Described embodiments read task data for scheduled tasks from systemmemory 210. Task data might be of variable size. Described embodimentsallow multiple threads of MTM 300 (e.g., tasks from multiple queues) toaccess system memory 210 to read the task data. Ordering is typicallyenforced on tasks from the same thread. Further, task data might bespeculatively fetched from system memory 210 to provide higherthroughput of MTM 300. As described herein, for each schedule operation,MTM 300 selects a queue to transmit one or more tasks (e.g., at step 616of FIG. 6). To transmit the task, the corresponding task data is readfrom system memory 210. A task read operation reads the queue (e.g., oneof queues 406) to determine a starting address of the task data insystem memory 210. A memory read request for the starting address of thetask data is sent to system memory 210. However, each queue 406 mighttrack only the size of the first task in the queue.

The task read operation reads the task data for the task at the head ofthe scheduled task queue from system memory 210. As described herein,the queue contains the head pointer of the task queue in memory andcontains the size of the task data of the task at the head of the queue.Task read operations might allow multiple threads (e.g., one queue perthread) to aggregate memory requests and sent multiple requests over onememory port to system memory 210. In some embodiments, task readoperations might have up to 4 threads (4 queues) active at a time. Thetask data returned from system memory 210 could be out of order and isordered through a re-order queue for each thread. Since a given queuestructure might only know the size of the data for the task at the headof its queue, memory read requests might be issued speculatively, whenpossible, when the same queue sends multiple tasks back-to-back. Such aspeculative read request avoids waiting for data corresponding to thefirst task to return from system memory 210 before knowing the size ofthe data for the task behind it. Described embodiments provide a taskread operations with multiple threads with speculative read operationsand ordering enforcement on returned data for each thread.

Speculative read operations provide the advantage of avoiding a wait forthe read of data for the task at the head of the queue to finish beingread from system memory 210 before learning the actual size of data forthe next task in the queue. When data for more than one task is readfrom system memory 210, the second and subsequent tasks are readspeculatively, since the actual size of the task data is not known. Theamount of data that is fetched from system memory 210 by the speculativeread operation might be configurable, and thus tuned for a given trafficpattern. If the size of task data fetched during a speculative read isgreater than the actual task size, the excess data might be used for thenext task in the same queue, or the excess data might be discarded.

Task read operations update the head pointer of the queue after the readhas been performed to point to the next task in the queue. Task readoperations also update the task size field with the corresponding taskdata size of the new head of queue task. In some embodiments, tasks arestored in system memory 210, for example as shown in FIG. 14 describedbelow. In some embodiments, the task stored in system memory 210includes a header that includes the task size (in a first 16 B), taskparameters, and the corresponding task data. The first dataword (16 B)of the task for a given task is read from system memory 210 when taskdata for a previous task in the same queue is read from system memory210. The read task size value is employed to update the queue structurewith an indicator corresponding to whether the size of the task data islarger than a predefined size (e.g., an indicator of a “large” task). Inthe event that the task is a “large task”, only the large task isscheduled by the scheduler, and no speculative read operation for thesubsequent task occurs.

Tasks might typically be stored in 2 KB blocks in system memory 210, andtasks might straddle 2 KB memory blocks. When a task straddles a memoryblock, the task data is parsed, and a next pointer field of the task isread, which is the last 16 B of the 2 KB block. This pointer is thelocation of the next memory read request. When all the read data comesback, the entire task becomes available. FIG. 14 shows a block diagramof an exemplary task queue structure. As shown in FIG. 14, data for afirst task 1402 is stored in the queue, beginning at Address 1. Taskdata 1402 is followed by data for a second task 1404 and data for athird task 1406. Task 1406 is followed by data for a fourth task 1408.However, task data 1408 exceeds a memory boundary of the first memoryblock of queue 1400. In exemplary embodiments of the present invention,the memory boundary of each block is 2 kB. Thus, task data 1408 isappended with pointer data 1410, which provides a pointer to a next,linked, block of system memory 210 where the remainder of data for thefourth task 1408 is stored, starting at Address 2. Empty space 1412 inthe second block is available for additional task data to be storedtherein.

FIG. 16 shows exemplary task data read operation 1600. At step 1602, atask data read operation is received by task read module 326 of MTM 300to read task data from system memory 210 for a certain queue. At step1604, if the received task data read request is non-speculative, then atstep 1606, task read module 326 assigns an empty thread to process thetask data read request such that no other active thread is accessingtask data for the same queue. At step 1604, if the received task dataread request is speculative (e.g., one or more back-to-back tasksscheduled from the same queue), then at step 1608, task read module 326determines if an active thread exists for the queue. If, at step 1608,an active thread does not exist, at step 1606, task read module 326assigns an empty thread to process the task data read request such thatno other active thread is accessing task data for the same queue. If, atstep 1608, an active thread does exist, at step 1610, task read module326 assigns the task read request to the already active thread for thesame queue. At step 1612, MTM 300 sends, via switch interface 314, readrequests to system memory 210 to read task data for tasks in the requestthread. The task data might be read into one of L1 caches 313 for a headand tail pointer of the task read thread. At step 1612, task read module326 might also send a request to queue engine 308 to update one or morecontrol data structure values corresponding to the queue, for examplethe head pointer of the queue, the head task size, etc. Queue engine 308might also decrement the one or more read tasks from schedulinghierarchy 400. At step 1614, if any active threads remain, threadprocessing returns to step 1612. At step 1614, if no active threadsremain, thread processing for task data read operations completes atstep 1616. A thread is active until all the tasks for that thread areread from system memory 210.

FIG. 17 shows a flow diagram of thread processing method of step 1612 ofFIG. 16. At step 1702, thread processing method 1612 starts. At step1704, task read module 326 reads the queue head pointer and task datasize for the head task from L1 cache 313. At step 1706, task read module326 determines whether the task read request straddles a memory boundaryof system memory 210 (e.g., a 2 kB boundary as described in regard toFIG. 14). If, at step 1706, the task read request straddles a memoryboundary of system memory 210, then at step 1708, the read request issplit into two or more read requests to read the task data from eachmemory block. After step 1708, or if, at step 1706, the task readrequest does not straddle a memory boundary of system memory 210, method1612 proceeds to step 1710. At step 1710, task read module 326 issues aread request for the task stored at the location indicated by the headpointer, and having a length indicated by the task data size. At step1710, task read module 326 might also issue a speculative read requestfor one or more subsequent tasks if one or more contiguous tasks for thesame queue can be scheduled simultaneously. The speculative read requestmight read task data from the task location following the head pointeroffset by the task data size, and might read data of a length equal tothe default task data size for the corresponding scheduling nodeassociated with the tasks. For example, task read module 326 might readthe next N*16 B of task data from system memory 210.

At step 1712, if the speculative read operation returned the entire datafor the speculatively read task(s), at step 1714, any extraneous data atthe end of the speculatively read data is discarded, and at step 1720,process 1612 completes. Any left over scheduling credits (e.g., trafficshaping credits) might be used for a next speculative task read. At step1712, if the speculative read operation did not return the entire datafor the speculatively read task(s), at step 1716, the actual task datasize for the speculatively read task is determined from the task header(e.g., the first 16 B of the task data). At step 1718, task read module326 issues a read request for the remaining task data, where the readrequest is based on the actual task data size from the task header. Atstep 1720, step 1612 completes.

In described embodiments, for a speculative read request at step 1710, aread request of size N*16 B is issued for the task, where N is aconfigurable positive integer set by control software of networkprocessor 100 (in some embodiments, N might default to 12). If there isany scheduling credit left from the previous speculative read, then aspeculative read request for a subsequent task might be equal to(N*credit)*16 B. The speculative read computes the read address from thelast read address and request size for that thread. If the speculativeread data is more than the task, the remaining data might be discarded,or might be used for a next task. When a thread becomes empty, any leftover data from speculative read operations might be discarded. Read datafrom system memory might be out of order and might be stored in a bufferfor each thread such that the data might be re-ordered. Task read module326 might select a thread to be read out in round robin fashion. Asdescribed herein, the queue structure contains the head pointer of thetask queue in memory. The queue structure also contains the size of thetask at the head of the queue. At step 1710, task read module 326 mightupdate the head pointer of the queue after the read has been performedand update the task data size field that indicates the size of the taskat the head of the queue. For this, the output task read block mightread 16 extra bytes from memory to retrieve the header of the next task.

Described embodiments provide a method to drain packets from a part of atraffic manager scheduling hierarchy. The structure of schedulinghierarchy 400 might be altered when conditions in the network change. Toalter the structure of scheduling hierarchy 400, MTM 300 might drain allthe tasks associated with a queue, scheduler, or branch of schedulinghierarchy 400. When a scheduler is drained, the entire branch under thescheduler is drained of tasks. Described embodiments provide a methodthat: 1) stops enqueuing any tasks on the queues that are part of thehierarchy to be drained and waits to ensure all task enqueue operationson the part of the hierarchy to be drained are complete before startingthe drain operation; 2) drains all tasks associated with a queue orscheduler (and the sub-tree underneath) in the hierarchy; 3) signals theend of steps (1) and (2) by generating an interrupt to a controlprocessor of network processor 100; 4) recovers all the memory used bydrained tasks when executing step (2); and 5) executes steps (1) and (2)without affecting the rest of scheduler hierarchy 400.

FIG. 15 shows a flow diagram of exemplary task drain operation 1500. Atstep 1502, task drain operation 1500 starts. When a queue or schedulershould be drained, at step 1504, the ID of the queue is programmed intoa configuration register, for example in block 312 of MTM 300. At step1506, if new tasks are received by MTM 300, the queue ID of the receivedtask is compared to the queue/scheduler ID of the scheduling tree branchto be drained at step 1508. If, at step 1508, the received task has thesame queue ID as the queue being drained, at step 1510 the receivedpacket is marked to be dropped by buffer manager 302. Step 1508 mightiteratively occur if one or more new tasks are received while a givenscheduling tree branch is being drained. After step 1510, drain process1500 proceeds to step 1514. Otherwise, at step 1508, if the receivedtask does not have the same queue ID as the queue being drained, at step1512 the received packet is enqueued in the corresponding queue, forexample as described in regard to FIG. 7. After step 1512, drain process1500 proceeds to step 1514. At step 1506, if no new tasks are received,drain process 1500 proceeds to step 1514. In some embodiments, steps1506, 1508 and 1510 might occur in parallel with step 1514.

At step 1514, MTM 300 determines whether all task enqueue operations arecomplete for the queue or scheduler branch to be drained. In someembodiments, MTM 300 might determine whether the task enqueue operationsare complete for all tasks for the queue to be drained by monitoringtask counts of scheduling nodes at three stages of the enqueue process:(1) monitor task count when tasks are received by MTM 300 (e.g., step602 of FIG. 6), which might be a count of tasks received; (2) monitortask count after buffer manager 302 has determined whether to accept ordrop the received tasks (e.g., step 708 of FIG. 7), which might be acount of tasks accepted for enqueuing; and (3) at the end of the taskenqueue operation (e.g., operation 606 of FIG. 7), which might be acount of tasks actually enqueued. For example, at step 1514, the countof tasks accepted and the count of tasks enqueued (e.g., task count (3))are compared. When the count of tasks accepted becomes equal to thenumber of tasks enqueued, then the enqueue pipeline is clear of “to bedrained” tasks. Task drain operation 1500 continues to step 151 6.

At step 1516, the queue or branch of scheduling hierarchy 400 to bedrained is removed from scheduling hierarchy 400, and the taskscorresponding to the queue/branch are placed in a drain FIFO buffer ofMTM 300. An indicator is set for a first drained task to indicate that adrain operation has been initiated (“first drain indicator”). A drainFSM inserts as many scheduling events into the pipeline of the givenqueue (and propagated up through scheduling hierarchy 400) as there aretasks in the drain FIFO. Each time the scheduling logic processes adrain packet, an indicator is set (“subsequent drain indicator”). Thefirst task corresponding to the first drain indicator is schedulednormally at step 1516, although the memory and state indicators for thedrained queue/branch are cleared up through scheduling hierarchy 400 atstep 1518. Tasks corresponding to “subsequent drain indicators” are readfrom system memory 210 and dropped at step 1516. At step 1520, spaceused by drained tasks in system memory 210 is now available forreallocation. Task drain process 1522 completes at step 1522 once thedrain FIFO is empty, the memory used in system memory 210 associatedwith the drained queue/branch is zero, or the linked list containing thechildren of the scheduler is empty.

In described embodiments, each node of scheduling hierarchy 400maintains a scheduling data structure which includes various controldata such as linked list pointers of the child nodes, statistics such astask count and memory used, characteristics such as the scheduling rateand scheduling algorithm, and various state indicators such asbackpressure events and timer events. The state indicators might alsoinclude an indicator that a node is removed from the schedulinghierarchy (an “in-hierarchy indicator”).

During scheduling, when a node with available tasks is selected by itsparent for scheduling, the parent checks the various state indicators todetermine whether the particular node might be scheduled (e.g., at step614 of FIG. 6). Rules for scheduling might be as follows: 1) if a nodeis backpressured, the node cannot be scheduled and is removed from thescheduling hierarchy (e.g., the in-hierarchy indicator is cleared); 2)if the node is in a timer state, the node cannot be scheduled, but thenode is not removed from the scheduling hierarchy (e.g., thein-hierarchy indicator is set); 3) if the node is neither backpressurednor in a timer state, the node can be scheduled (e.g., the“in-hierarchy” indicator is set). The in-hierarchy indicator is clearedwhen the task count for a node becomes zero and the node is removed fromthe linked list of active nodes, or when the node becomes backpressured.The in-hierarchy indicator is set for a scheduling node when (i) a taskis enqueued and the node is not backpressured, or (ii) when the node isre-enqueued having a non-zero task count.

Any processing module in network processor 100 might generate a messagedirected for a particular node in scheduling hierarchy 400 to set orrelease the backpressure state. Described embodiments also allow anynode at any level in the scheduling hierarchy to be controlled usingbackpressure (e.g., previously queues were the typical places where abackpressure might be applied). Since described embodiments provide theflexibility of a scheduler being backpressured, a partial tree from thescheduling hierarchy can be effectively backpressured and taken off-linefor scheduling purposes.

Described embodiments provide a mechanism to dynamically controlscheduling hierarchy 400 where one or more scheduling nodes have abackpressure or other timer event. A timer event is typically used tocontrol the scheduling rates, for example to meet a traffic shapingconstraint, and a backpressure event is usually caused by a resourceavailability constraint by a processing module of network processor 100that receives tasks from MTM 300. When a scheduling node is subject to abackpressure or timer event, tasks from the corresponding schedulingnode and its child nodes (if any) are prevented from being scheduled.When a scheduling node is released from a backpressure or timer event,tasks from the scheduling node and its child nodes (if any) becomereavailable for scheduling (e.g., a re-enqueue operation as described inregard to FIG. 8).

Described embodiments provide that corresponding data structures foreach scheduling node maintain one or more status indicators to representthe state of backpressure and timer events and whether the node isavailable for scheduling. When a node is subject to a backpressure ortimer event, the node is removed from the parent scheduler's list ofactive nodes to schedule. Queue and scheduler levels are encoded intheir respective IDs, which enables detecting and directing of incomingrequests for backpressure and timer events for the target ID. Anyprocessing module (e.g., one of μP cores 106 or hardware accelerators108) of network processor 100 might request a backpressure event for aparticular scheduling node, for example if the processing module cannotaccept another task from that node.

A scheduler might create a timer event if the scheduling rate for aparticular scheduling node exceeds the constraints imposed on its rate(e.g., at steps 806 to 812 of FIG. 8). The scheduler updates the timerindicator in the scheduling data structure of that node to indicate thenode has a timer event. When the particular duration has elapsed, thetimer sends a request to reset the timer bit. The backpressure releaseand the resetting of the timer bit have similar effect on the schedulingnode—making the node available for scheduling within hierarchy 400.

When scheduler logic encounters a node having its timer indicator orbackpressure indicator set, the scheduler takes the node out of thescheduling hierarchy and sends a “response” message to its parent toremove this node from its parent's list of active nodes for scheduling.Thus, this node is no longer available for scheduling until a re-enqueueoperation occurs (e.g., step 812).

FIG. 18 shows a flow diagram of exemplary backpressure or timer requestprocess 1800. At step 1802, a backpressure request or a timer request isreceived by MTM 300 from a processing module of network processor 100for a given scheduling node of hierarchy 400. At step 1804, thescheduling data structure for the target scheduling node is read fromone of system memory 210 to one of L1 caches 313. At step 1806, thecorresponding backpressure or timer status indicator is updated toreflect to the received request, and, if necessary, the in-hierarchystatus indicator is updated to reflect that the node is removed fromscheduling hierarchy 400. At step 1808, the updated scheduling datastructure is written back to system memory 210.

At step 1810, once a backpressure release request or a timer releaserequest is received by MTM 300 corresponding to the backpressure requestor timer request received at step 1802, processing continues to step1812. At step 1812, the scheduling data structure for the targetscheduling node is read from one of system memory 210 to one of L1caches 313. At step 1814, if the task count for the node is non-zero,then at step 1818, the corresponding backpressure and timer indicatorsare updated, and the node is re-enqueued in scheduling hierarchy 400,for example by updating the in-hierarchy status indicator. At step 1820,the updated scheduling data structure is written to system memory 210.At step 1822, backpressure and timer request process 1800 completes.

If, at step 1814, the node has a task count equal to zero, at step 1816,the corresponding backpressure and timer indicators are updated, but thenode is not necessarily re-enqueued in scheduling hierarchy 400 untilone or more tasks are enqueued in the node. At step 1820, the updatedscheduling data structure is written to system memory 210. At step 1822,backpressure and timer request process 1800 completes. Process 1800might be repeated at each parent level of scheduling hierarchy 400 abovethe requested node, such that task counts and status indicators at eachparent level are updated accordingly to the received backpressure ortimer request.

Thus, as described herein, embodiments of the present invention providedynamic control of specific nodes in scheduling hierarchy 400 usingbackpressure and timer indicators. Nodes are removed from schedulinghierarchy 400 when backpressured or in a timer event, and nodes areadded back in to scheduling hierarchy 400 when the backpressure or timerevent is complete. A node at any level in scheduling hierarchy 400 mightbe controlled by the backpressure and timer events, and might be eithera queue or a scheduler.

As described herein, in embodiments of scheduling hierarchy 400, eachlevel in hierarchy requires the processing of enqueue and dequeueoperations. State machines for the enqueue and dequeue operations mightrequire exclusive accesses to one or more data structures of schedulinghierarchy 400 (e.g., the scheduling data structures) while stillallowing read and write accesses to other data structures of schedulinghierarchy 400. As described, each node of scheduling hierarchy 400generally interacts directly only with its parent node and childnode(s). Changing the structure of scheduling hierarchy 400 (e.g.,removing a branch or scheduling level, etc.) potentially requiresupdating multiple parent and child levels of scheduling hierarchy 400.

Scheduling hierarchy 400 includes one or more finite state machines(FSMs), for example in scheduler 310, to perform enqueue, dequeue,re-enqueue and scheduling operations. Each FSM typically might requireexclusive access to the queue or scheduler data structure beingprocessed. One or more entries in the corresponding scheduling datastructures might be reserved for updates by the FSMs. Some entries mightbe exclusive to a given FSM, while others are shared among two or moreFSMs. Further, to update its own reserved entries, an FSM might copywhole data structures without another FSM updating other bytes of thatdata structure in parallel. Apart from the FSMs, other accesses to thesedata structures are non-blocking. For the FSMs, the priority to accessdata structures, as well as interactions with parent and child nodeupdates is defined to avoid architectural deadlock. The order ofexecution among various FSMs and functions enables fast hardwareimplementations of the scheduling FSMs.

As described herein, an enqueue FSM might perform a task enqueueoperation (e.g., as shown in FIG. 7). The task enqueue operation mightoccur at multiple levels of scheduling hierarchy 400 for any given task.The queue for the task is fetched from system memory along with allparents up to the root scheduler (e.g., step 704). Active and pendinglists are updated based on the node characteristics (e.g., step 708).Statistics such as task count and used memory are updated (e.g., step710). The updated task count is sent to the parent scheduler (e.g., step710).

A dequeue FSM might perform a task dequeue operation (e.g., as shown inFIG. 9). When one or more tasks are available at the root scheduler, thescheduler schedules one or more tasks from one of its children (e.g.,step 616 of FIG. 6). A message is sent to the child (a scheduler or aqueue) about the tasks being scheduled from that child (e.g., step 904of FIG. 9). The child responds to the schedule message indicatingwhether it accepted the schedule (e.g., step 906). Based on the child'sresponse, the scheduler updates its own task count for that child (e.g.,step 908). Further, in case the constraints such as the shaping ratesfor this scheduler dictates, this scheduler could be made to wait forcertain time duration (e.g., steps 806 through 812 of FIG. 8). Thescheduling cycle might repeat at each scheduler level for subsequenttasks. Additionally, upon receiving a schedule message from its parent(as at step 904), the child node might start its own scheduling cyclesuch as shown in FIG. 9. The queue node determines the actual number oftasks being scheduled and propagates the corrected task count (e.g., atstep 912) through scheduling hierarchy 400.

As described, re-enqueue operations might occur when a given nodeexceeds its scheduling rate, and the node is temporarily removed fromscheduling hierarchy 400 for a computed time duration. After servingthis duration, the node is added back to scheduling hierarchy 400 via are-enqueue operation. This operation is similar to the enqueue operationexcept that, the number of tasks added back to the parent is the totalnumber available at this node, and there is no new memory usage added toscheduling hierarchy 400.

A link operation occurs whenever an enqueue or dequeue operation isperformed at a scheduler which adds to the tail of the linked list ofactive child nodes. The tail scheduler or queue receives a link messageand updates its next pointer to the new tail. The parent waits for thecompletion message to go forward with the remaining part of its enqueueor dequeue operation.

In described embodiments, there is an L1 cache module (e.g., one of L1caches 313) for each scheduler level (other than root scheduler 402) andone for the queue level of scheduling hierarchy 400. The enqueue FSMallocates the queue in the queue L1 cache at the start of the enqueueprocess. The enqueue operation starts at the queue level, andprogressively works its way through the levels of scheduling hierarchyup to the root scheduler. The dequeue operation starts at the rootscheduler and works its way through the scheduling hierarchy to thequeue level (and eventually to the task). Based on the level of theparent of the queue, the scheduler's from parent level onwards isallocated by modules per level. Upon completion of enqueue operations,these entries in the L1 cache are de-allocated per level. The dequeueoperation is similar to enqueue, with the difference being that itallocates the scheduler per level, starting from the first level ofschedulers below root scheduler 402, proceeding to the queue level.After the end of a dequeue operation, all entries in the L1 cache aredeallocated per level.

The re-enqueue operation starts at the level the particular node is inthe scheduling hierarchy and progressively reaches root scheduler 402.The link operation is initiated by a scheduler level and competed eitherby its child scheduler at immediately lower than itself or by its childqueue. Thus, each level might have one or more FSMs working for each ofthese operations simultaneously. An exemplary interaction for theseoperations for scheduling data structure accesses is as follows:

-   -   a. An FSM reserves the scheduling data structure for its        exclusive modifications. An FSM works only on the bytes/cache        lines reserved for it, or shared for update among two or more        FSMs.    -   b. Scheduler access to the scheduling data structure to prepare        a schedule has the highest priority.    -   c. Dequeue operations to update the task count and list pointers        is the next highest priority, because it schedules tasks for        transmission, thereby reducing the tasks in MTM 300 by        delivering them to their destination.    -   d. A re-enqueue operation adds back an existing node to        scheduling hierarchy 400, and gets a higher preference than an        enqueue operation.    -   e. The enqueue brings a fresh packet into MTM 300 and hence is        the lowest priority for processing a scheduling data structure        over operations for tasks that have already been received.    -   f. A link operation has exclusive access to its field in any        data structure. Further, the only other time this field is        modified (by an enqueue) is for the first enqueue operation for        this structure. So, the link operation does not need an explicit        priority.    -   g. Propagation of messages occurs throughout scheduling        hierarchy 400 for a task dequeue operation, a task enqueue        operation and a re-enqueue operation. For each operation        requiring a propagation of the output to the parent or the child        level enters the arbitration for data structures based on the        availability of space at the output.

Thus, described embodiments provide a modularized and distributedhardware implementation of a high performance scheduler. A modularizedimplementation also provides flexibility in adding or subtracting aparticular level (target level) in the scheduling hierarchy by simpleconnections between respective parent and child levels of the targetlevel. This addition or subtraction might be done in hardware orsoftware.

During enqueue and dequeue operations, the various FSMs might access oneor more data structures stored in L1 caches 313, each data structurecorresponding to a given queue or scheduler. Each data structure mighthave one or more data fields, where each data field might be reservedfor modification by less than all of the FSMs, or might be generallyavailable to all the FSMs. Therefore, embodiments of the presentinvention provide a method for allowing read-only write access orlocked/mutually exclusive (mutex) access to one or more data fields ofthe data structures. Thus, flexible access to the data structures fromone or more threads might be provided, while also maintaining datacoherency across multiple operations.

As described herein, enqueue and re-enqueue operations (e.g., FIG. 7),add one or more tasks to scheduling hierarchy 400, either when a task isreceived by MTM 300 (enqueue operation) or when a given scheduling nodesatisfies scheduling/shaping constraints and is made available forscheduling by MTM 300 (re-enqueue operation). Upon either an enqueue orre-enqueue operation, the various control and status data structures ofeach queue and each corresponding parent scheduler up to root scheduler402 are updated, for example to reflect an updated task count, amount ofmemory used, head and tail pointers of the data structures, and so on(e.g., at steps 708 and 710 of FIG. 7). Further, as described herein, adequeue operation (e.g., FIG. 9) removes one or more tasks fromscheduling hierarchy 400 when tasks are scheduled for transmission byMTM 300. As described, in a dequeue operation, a parent schedulerselects a child node for scheduling based upon one or more correspondingdata structures of the parent scheduler. The selected child noderesponds to the parent scheduler, and the parent scheduler updates thevarious data structures (e.g., task counts and list pointers at step908). The process iteratively repeats at each level of schedulinghierarchy down to a selected queue node.

Other than enqueue, re-enqueue and dequeue operations, other FSMs of MTM300 might access the various status and control data structure of thevarious nodes of scheduling hierarchy 400. For example, the amount ofmemory used by various tasks of a node might change during operation ofMTM 300, or memory might be released from use at some time after a taskhas been dequeued, and a message to update the memory used might bepropagated through scheduling hierarchy 400 as a background operation inaddition to the regular scheduling operations. Additionally, one or moreoperations, such as buffer management and traffic shaping, might accessvarious data fields from the control and status data structures. Lastly,during operation of MTM 300, various pointers corresponding to thememory blocks used by the corresponding task data might be updated, forexample to indicate a new memory block is added to store task data(e.g., pointer data 1410 of FIG. 14).

As described herein, the various control and status data structures ofscheduling hierarchy 400 are stored in L1 caches 313. Queue engine 308requests the data structures from L1 caches 313 on an as-needed basis.As described herein, data stored in system memory 210 might be stored inL1 caches 313 during processing. Described embodiments might providefour types of access for queue engine 308 to L1 caches 313: (1) simpleread access, (2) simple write access, (3) locked read access, and (4)locked write access. Simple read access requests and simple write accessrequests are processed regardless of the status of a lock being placedon the requested data structure. Thus, a simple read access or a simplewrite access might correspond to data fields that modified by only onethread of MTM 300, since there would be no need to lock the datastructure. A locked read access or a locked write access occurs onlywhen the requested data structure is unlocked. The locked requestupdates a lock status of the data structure to provide exclusive accessto data fields that might be modified by more than one thread of MTM300, thus a need might exist to maintain data coherency between one ormore thread operations of MTM 300.

In described embodiments, a lock of a data structure might vary in timefrom one cycle to typically multiple cycles of the network processordepending upon the nature of the locked access request. Similarly, atime gap between accesses to a lock from the same FSM, thread, or moduleof MTM 300 might be enforced as a configurable number of O-M cycles ofthe network processor, where M is a positive integer.

Embodiments of the present invention provide two access arbiters (e.g.,as part of queue engine 308 of FIG. 3) between MTM 300 and L1 caches313, for example at each port of L1 caches 313 (e.g., a read port and awrite port of the memory). A first arbiter might arbitrate betweensimple access requests from the various threads and modules of MTM 300.A second arbiter might be an “address mutex arbiter” that arbitratesbetween locked access requests from the various threads and modules ofMTM 300 that require exclusive access to L1 caches 313. The simplearbiter might be implemented as any type of arbiter, for example, afixed priority or round robin arbiter.

FIG. 19 shows an exemplary logical block diagram of the simple andaddress mutex arbiters of queue engine 308. As shown in FIG. 19, queueengine 308 might include address mutex arbiter 1902 and simple arbiter1906. In some embodiments, simple arbiter 1906 might include one or moresimple arbiters, shown as simple arbiters 1906(1)-1906(N). Inembodiments having multiple simple arbiters, each simple arbiter1906(1)-1906(N) might be dedicated to arbitrate simple access requestsof a given type, for example, each of read requests, write requests,memory allocation requests, and L1 cache requests might have acorresponding simple arbiter 1906(1)-1906(4). As shown in FIG. 19, MTM300 might include one or more finite state machines (FSMs)1904(1)-1904(Y) that might request access to data stored in systemmemory 210. Similarly, queue engine (QE) 308 might include one or moreQE FSMs 1908(1)-1908(X) that might request access to data stored insystem memory 210. As shown, each of FSMs 1904(1)-1904(Y) and QE FSMs1908(1)-1908(X) are in communication with simple arbiter 1906 (or acorresponding one of simple arbiters 1906(1)-1906(M), and L1 caches 313.Each of FSMs 1904(1)-1904(Y) and QE FSMs 1908(1)-1908(X) mightoptionally be in communication with address mutex arbiter 1902, asindicated by the dashed lines. For example, only corresponding ones ofFSMs 1904(1)-1904(Y) and QE FSMs 1908(1)-1908(X) that require coherentdata accesses might be in communication with address mutex arbiter 1902.

Address mutex arbiter 1902 might receive locked access requests fromeach source of MTM 300 that requires exclusive memory access (e.g.,corresponding ones of FSMs 1904(1)-1904(Y) and QE FSMs 1908(1)-1908(X)).Each request might include the memory address requested and a priorityfield for indicating a priority level of the access request. FIG. 20shows exemplary address mutex arbitration method 2000. At step 2002,address mutex arbiter 1902 receives one or more locked access requeststo L1 caches 313 from one or more modules of MTM 300. At step 2004, thememory address corresponding to each of the one or more received accessrequests is determined. At step 2006, address mutex arbiter 1902determines if the received requests are for the same addresssimultaneously. If the received requests are for unique addresses, then,at step 2012, address mutex arbiter 1902 determines whether any of theone or more received requests are for an address already locked out by aprevious access request. For example, address mutex arbiter 1902 mightmaintain a dynamic table of locked addresses. If, at step 2006, multipleof the one or more received access requests are for the same address,then, at step 2008, address mutex arbiter 1902 might allow access to anyrequest for a unique address, and the received request having thehighest priority value for the conflicting address. The one or morelower priority access requests for the conflicting address might bequeued at step 2010. Process 2000 might then proceed to step 2012 todetermine whether any of the received requests for unique addresses arefor an address already locked out by a previous access request.

At step 2012, address mutex arbiter 1902 determines if any of thereceived requests for unique addresses are locked out by a prior accessrequest, for example if one or more of the requested addresses areindicated as locked in the locked address table. If, at step 2012, oneor more of the requested addresses are locked, at step 2014, the one ormore access requests for one or more locked addresses might be queued.Process 2000 then proceeds to step 2016. If, at step 2012, none of therequested addresses are locked, process 2000 proceeds to step 2016. Atstep 2016, address mutex arbiter 1902 grants access to the one or morerequested addresses of L1 caches 313 corresponding to the one or morerequests that are not locked out by prior accesses. At step 2020,process 2000 completes. In some embodiments, the tests of steps 2006 and2012 might occur in any order, or might occur substantiallysimultaneously.

In embodiments of the present invention, a lock grant (e.g., as grantedat step 2016) is maintained either for a predetermined number of cyclesof network processor 100, or might be unlocked when a release signal isreceived from the requestor. Thus, a lock grant might stay locked forone or more cycles of the network processor. FIG. 21 shows an exemplaryflow diagram of lock release process 2100. At step 2102, the addressmutex arbiter receives a release request from a corresponding thread ormodule of MTM 300, or address mutex arbiter 1902 receives a timer event,for example from timers and clocks interface 320, indicating that theassociated predetermined number of cycles has elapsed. At step 2104,address mutex arbiter 1902 releases the lock on the one or moreaddresses corresponding to the release request. At step 2106, addressmutex arbiter 1902 determines if one or more lower priority or lockedout requests are queued for the one or more released addresses. If oneor more requests are queued, at step 2108, address mutex arbiter 1902determines whether one or more of the queued requests are consecutiverequests for the same address from the same source requestor.

If, at step 2108, one or more of the queued requests are consecutiverequests for the same address from the same source requestor, at step2109, address mutex arbiter 1902 determines whether one or more lowerpriority requests are queued for the address. If, at step 2109, one ormore lower priority requests are queued, at step 2110, address mutexarbiter 1902 disallows access by the consecutive request for eachaddress, and grants access to a lower priority request for the addressthus allowing a lower priority requestor to have a request processedafter a release by the higher priority requestor, and preventing lowpriority requests from being locked out by high priority requests. Afterstep 2110, process 2100 proceeds to step 2114. If, at step 2109, nolower priority requests are queued, at step 2111, address mutex arbiter1902 allows access by the consecutive request for each address. If, atstep 2108, none of the queued requests are consecutive requests for thesame address from the same source requestor, at step 2112, the addressmutex arbiter grants access for the one or more queued requests, forexample by process 2000 as shown in FIG. 20. At step 2114, the addressmutex arbiter updates the locked address table corresponding to the oneor more addresses having queued requests that are now active, andprocess 2100 proceeds to step 2116. If there are no requests queued,lock release process 2100 completes at step 2116.

Thus, as described, embodiments of the present invention provide thatsimple read or write operations are granted access to L1 caches 313 by asimple arbitration process, such as strict priority or round robin, andone or more simple requests might be active for a given addresssimultaneously. Locked requests that enforce coherency might be grantedaccess to L1 caches 313 based on the address of the request, followed bypriority level for access requests to the same address, and then byhistory such that consecutive requests to the same address by the samerequestor do not prevent access by a lower priority request. Multiplerequests for unique addresses are processed simultaneously in parallelexecution on one or more data structures in L1 caches 313, thusimproving memory throughput, while also maintaining data coherency.

As described herein, referring to FIG. 5, each task 500 might include ashared parameter ID 508 that points to a shared parameter entry storedin a shared parameter data structure in system memory 210. In someembodiments, the shared parameter entry might be 32 bytes. Tasks mappedto different queues at any level might have the same shared parameter IDto enable data sharing among the various tasks. In addition, the sharedparameter data structure might be optionally associated with a queue,providing additional parameters for the queue. In some embodiments, aseparate L1 cache 313 might be employed to store the shared parameterdata for queues that are being worked on by MTM 300. Describedembodiments provide flexible data sharing among various queues ofscheduler 400 through shared parameters. Shared parameters provide anability to share data between any queues or any set of tasks mapped tosame or different queues. The shared parameter ID might be assignedeither per-task, or per-queue. For example, a shared parameter ID mightbe selected based on either a task (e.g., shared parameter ID 508) orthe queue ID (e.g., the queue of scheduling hierarchy 400 associatedwith the task).

Shared parameters are loaded into buffer manager 302 during a taskenqueue operation (e.g., at step 704 as shown in FIG. 7). During dequeueoperations (e.g., at step 914 as shown in FIG. 9), the shared parameterdata might be employed to affect traffic shaping or to maintainstatistics in the shared parameter data. The shared parameter data mightbe employed to affect a task discard decision or to maintain task orqueue statistics in the shared parameter data block. As described, ashared parameter ID for a task is selected either from the task itselfor from the queue. If the task has valid a shared parameter value infield 508, then that shared parameter ID is selected, otherwise theshared parameter ID in the queue structure is selected, if valid. Apredetermined parameter ID value might be employed as an “invalidindicator” (e.g., a shared parameter value of 0xFFFFFF). In someembodiments, the shared parameter ID value might be a 24-bit value wherethe upper 4-bits index to one of 16 memory-mapping tables (softwareconfigurable). Each memory-mapping table converts the lower 20-bits ofthe ID to a physical memory address where that shared parameter data isstored (32 Bytes) in system memory 210. The shared parameter data isfetched from system memory 210 along with the task data and queue andscheduler control data.

Thus, as described herein, embodiments of the present invention providefor dynamically controlling a scheduling rate of each node in ascheduling hierarchy of a network processor. A traffic manager generatesa scheduling hierarchy that is a tree structure having a root schedulerand N scheduler levels. The network processor generates taskscorresponding to received packets. A traffic manager enqueues receivedtasks in a queue of the scheduling hierarchy associated with a data flowof the task. The queue has a parent scheduler at each level of thehierarchy up to the root scheduler. The traffic manager maintains one ormore scheduling data structures for each node in the schedulinghierarchy. If the traffic manager receives a rate reduction requestcorresponding to a given node of the scheduling hierarchy, the trafficmanager updates one or more indicators in the scheduling data structurecorresponding to the given node and removes the given node from thescheduling hierarchy, thereby reducing the scheduling rate of the givennode.

Reference herein to “one embodiment” or “an embodiment” means that aparticular feature, structure, or characteristic described in connectionwith the embodiment can be included in at least one embodiment of theinvention. The appearances of the phrase “in one embodiment” in variousplaces in the specification are not necessarily all referring to thesame embodiment, nor are separate or alternative embodiments necessarilymutually exclusive of other embodiments. The same applies to the term“implementation.” As used in this application, the word “exemplary” isused herein to mean serving as an example, instance, or illustration.Any aspect or design described herein as “exemplary” is not necessarilyto be construed as preferred or advantageous over other aspects ordesigns. Rather, use of the word exemplary is intended to presentconcepts in a concrete fashion.

While the exemplary embodiments of the present invention have beendescribed with respect to processing blocks in a software program,including possible implementation as a digital signal processor,micro-controller, or general purpose computer, the present invention isnot so limited. As would be apparent to one skilled in the art, variousfunctions of software might also be implemented as processes ofcircuits. Such circuits might be employed in, for example, a singleintegrated circuit, a multi-chip module, a single card, or a multi-cardcircuit pack.

Additionally, the term “or” is intended to mean an inclusive “or” ratherthan an exclusive “or”. That is, unless specified otherwise, or clearfrom context, “X employs A or B” is intended to mean any of the naturalinclusive permutations. That is, if X employs A; X employs B; or Xemploys both A and B, then “X employs A or B” is satisfied under any ofthe foregoing instances. In addition, the articles “a” and “an” as usedin this application and the appended claims should generally beconstrued to mean “one or more” unless specified otherwise or clear fromcontext to be directed to a singular form.

Moreover, the terms “system,” “component,” “module,” “interface,”,“model” or the like are generally intended to refer to acomputer-related entity, either hardware, a combination of hardware andsoftware, software, or software in execution. For example, a componentmay be, but is not limited to being, a process running on a processor, aprocessor, an object, an executable, a thread of execution, a program,and/or a computer. By way of illustration, both an application runningon a controller and the controller can be a component. One or morecomponents may reside within a process and/or thread of execution and acomponent may be localized on one computer and/or distributed betweentwo or more computers.

As used herein in reference to an element and a standard, the term“compatible” means that the element communicates with other elements ina manner wholly or partially specified by the standard, and would berecognized by other elements as sufficiently capable of communicatingwith the other elements in the manner specified by the standard. Thecompatible element does not need to operate internally in a mannerspecified by the standard.

Also for purposes of this description, the terms “couple,” “coupling,”“coupled,” “connect,” “connecting,” or “connected” refer to any mannerknown in the art or later developed in which energy is allowed to betransferred between two or more elements, and the interposition of oneor more additional elements is contemplated, although not required.Conversely, the terms “directly coupled,” “directly connected,” etc.,imply the absence of such additional elements. Signals and correspondingnodes or ports might be referred to by the same name and areinterchangeable for purposes here.

Although the subject matter described herein may be described in thecontext of illustrative implementations to process one or more computingapplication features/operations for a computing application havinguser-interactive components the subject matter is not limited to theseparticular embodiments. Rather, the techniques described herein can beapplied to any suitable type of user-interactive component executionmanagement methods, systems, platforms, and/or apparatus.

The present invention can be embodied in the form of methods andapparatuses for practicing those methods. The present invention can alsobe embodied in the form of program code embodied in tangible media, suchas magnetic recording media, optical recording media, solid statememory, floppy diskettes, CD-ROMs, hard drives, or any othernon-transitory machine-readable storage medium, wherein, when theprogram code is loaded into and executed by a machine, such as acomputer, the machine becomes an apparatus for practicing the invention.The present invention can also be embodied in the form of program code,for example, whether stored in a non-transitory machine-readable storagemedium, loaded into and/or executed by a machine, or transmitted oversome transmission medium or carrier, such as over electrical wiring orcabling, through fiber optics, or via electromagnetic radiation,wherein, when the program code is loaded into and executed by a machine,such as a computer, the machine becomes an apparatus for practicing theinvention. When implemented on a general-purpose processor, the programcode segments combine with the processor to provide a unique device thatoperates analogously to specific logic circuits. The present inventioncan also be embodied in the form of a bitstream or other sequence ofsignal values electrically or optically transmitted through a medium,stored magnetic-field variations in a magnetic recording medium, etc.,generated using a method and/or an apparatus of the present invention.

It should be understood that the steps of the exemplary methods setforth herein are not necessarily required to be performed in the orderdescribed, and the order of the steps of such methods should beunderstood to be merely exemplary. Likewise, additional steps might beincluded in such methods, and certain steps might be omitted orcombined, in methods consistent with various embodiments of the presentinvention.

It will be further understood that various changes in the details,materials, and arrangements of the parts which have been described andillustrated in order to explain the nature of this invention might bemade by those skilled in the art without departing from the scope of theinvention as expressed in the following claims.

1. A method of dynamically controlling a scheduling rate of each node ina scheduling hierarchy of a network processor having a plurality ofprocessing modules and at least one shared memory with packet data, themethod comprising: generating, by a traffic manager of the networkprocessor, a scheduling hierarchy comprising a tree structure of a rootscheduler and N scheduler levels, wherein a scheduler is a branch nodeand a queue is a leaf node of the scheduling hierarchy, wherein N is apositive integer; generating, by the network processor, one or moretasks corresponding to each of a plurality of received packetsassociated with one or more data flows of the network processor;enqueuing, by the traffic manager, a task provided by one of theplurality of processing modules of the network processor to anassociated queue of the scheduling hierarchy, wherein the queue isassociated with a data flow corresponding to the received task, thequeue having a corresponding parent scheduler at each of one or morenext levels of the scheduling hierarchy up to the root scheduler;maintaining one or more scheduling data structures for each node in thescheduling hierarchy; receiving a rate reduction request correspondingto a given node of the scheduling hierarchy; updating one or moreindicators in the scheduling data structure corresponding to the givennode; and removing the given node from the scheduling hierarchy by acorresponding parent scheduler of the given node, thereby reducing thescheduling rate of the given node.
 2. The method of claim 1, wherein therate reduction request is one of a backpressure request by one of theprocessing modules to reduce a scheduling rate of the given node and atimer event request by the corresponding parent scheduler of the givennode.
 3. The method of claim 2, wherein the step of updating one or moreindicators in the scheduling data structure corresponding to the givennode further comprises: if the rate reduction request is a backpressurerequest, setting a backpressure indicator of the scheduling datastructure corresponding to the given node; and if the rate reductionrequest is a timer event request, setting a timer indicator of thescheduling data structure corresponding to the given node.
 4. The methodof claim 1, wherein the step of removing the given node from thescheduling hierarchy by a corresponding parent scheduler of the givennode comprises: setting one or more status indicators of thecorresponding parent scheduler, wherein the one or more statusindicators comprise an active list of the corresponding parentscheduler, wherein the given node is indicated as inactive.
 5. Themethod of claim 1, further comprising: reading the scheduling datastructure from a level one (L1) cache of the traffic manager; andwriting the updated scheduling data structure to the L1 cache.
 6. Themethod of claim 1, further comprising: receiving a rate reductionrelease request corresponding to the given node; reading the schedulingdata structure corresponding to the given node from the L1 cache;determining a task count corresponding to the given node based on thescheduling data structure; if the task count is non-zero: re-enqueuingthe given node in the scheduling hierarchy; updating one or moreindicators in the scheduling data structure corresponding to the givennode indicating that the given node is released from the rate reductionrequest; and writing the updated scheduling data structure to the L1cache.
 7. The method of claim 6, wherein the step of re-enqueuing thegiven node in the scheduling hierarchy comprises: providing a re-enqueuerequest to the corresponding parent scheduler of the given node, whereinthe re-enqueue request comprises a node ID value of the given node; andupdating, by the corresponding parent scheduler, one or more statusindicators corresponding to the given node.
 8. The method of claim 7,wherein the one or more status indicators comprise a pending list of thecorresponding parent schedule, wherein the given node is indicated aspending, thereby replacing the given node in the scheduling hierarchy.9. The method of claim 8, further comprising: scheduling, by the parentscheduler, corresponding child nodes on a corresponding active list; andif no active child nodes remain, scheduling corresponding child nodesfrom the pending list.
 10. The method of claim 6, wherein the ratereduction release request is one of a backpressure release request byone of the processing modules to return to a given scheduling rate ofthe given node and a timer release request by the corresponding parentscheduler of the given node.
 11. The method of claim 10, comprising:sending the timer release request after a predetermined amount of timeelapses.
 12. A non-transitory machine-readable medium, having encodedthereon program code, wherein, when the program code is executed by amachine, the machine implements a method of dynamically controlling ascheduling rate of each node in a scheduling hierarchy of a networkprocessor having a plurality of processing modules and at least oneshared memory with packet data, the method comprising: generating, by atraffic manager of the network processor, a scheduling hierarchycomprising a tree structure of a root scheduler and N scheduler levels,wherein a scheduler is a branch node and a queue is a leaf node of thescheduling hierarchy, wherein N is a positive integer; generating, bythe network processor, one or more tasks corresponding to each of aplurality of received packets associated with one or more data flows ofthe network processor; enqueuing, by the traffic manager, a taskprovided by one of the plurality of processing modules of the networkprocessor to an associated queue of the scheduling hierarchy, whereinthe queue is associated with a data flow corresponding to the receivedtask, the queue having a corresponding parent scheduler at each of oneor more next levels of the scheduling hierarchy up to the rootscheduler; maintaining one or more scheduling data structures for eachnode in the scheduling hierarchy; receiving a rate reduction requestcorresponding to a given node of the scheduling hierarchy; updating oneor more indicators in the scheduling data structure corresponding to thegiven node; and removing the given node from the scheduling hierarchy bya corresponding parent scheduler of the given node, thereby reducing thescheduling rate of the given node.
 13. The non-transitorymachine-readable medium of claim 12, wherein the rate reduction requestis one of a backpressure request by one of the processing modules toreduce a scheduling rate of the given node and a timer event request bythe corresponding parent scheduler of the given node.
 14. Thenon-transitory machine-readable medium of claim 12, wherein the step ofupdating one or more indicators in the scheduling data structurecorresponding to the given node further comprises: if the rate reductionrequest is a backpressure request, setting a backpressure indicator ofthe scheduling data structure corresponding to the given node; and ifthe rate reduction request is a timer event request, setting a timerindicator of the scheduling data structure corresponding to the givennode.
 15. The non-transitory machine-readable medium of claim 12,wherein the step of removing the given node from the schedulinghierarchy by a corresponding parent scheduler of the given nodecomprises: setting one or more status indicators of the correspondingparent scheduler, wherein the one or more status indicators comprise anactive list of the corresponding parent scheduler, wherein the givennode is indicated as inactive.
 16. The non-transitory machine-readablemedium of claim 12, further comprising: receiving a rate reductionrelease request corresponding to the given node; reading the schedulingdata structure corresponding to the given node from an L1 cache;determining a task count corresponding to the given node based on thescheduling data structure; if the task count is non-zero: re-enqueuingthe given node in the scheduling hierarchy; updating one or moreindicators in the scheduling data structure corresponding to the givennode indicating that the given node is released from the rate reductionrequest; and writing the updated scheduling data structure to the L1cache.
 17. The non-transitory machine-readable medium of claim 16,wherein the step of re-enqueuing the given node in the schedulinghierarchy comprises: providing a re-enqueue request to the correspondingparent scheduler of the given node, wherein the re-enqueue requestcomprises a node ID value of the given node; and updating, by thecorresponding parent scheduler, one or more status indicatorscorresponding to the given node, wherein the one or more statusindicators comprise a pending list of the corresponding parent schedule,wherein the given node is indicated as pending, thereby replacing thegiven node in the scheduling hierarchy.
 18. The non-transitorymachine-readable medium of claim 17, further comprising: scheduling, bythe parent scheduler, corresponding child nodes on a correspondingactive list; and if no active child nodes remain, schedulingcorresponding child nodes from the pending list.
 19. A network processorcomprising: a plurality of processing modules and at least one sharedmemory with packet data, wherein one of the plurality of processingmodules is configured to generate one or more tasks corresponding toeach of a plurality of received packets associated with one or more dataflows; a traffic manager of the network processor configured to: receivea task corresponding to a data flow, the task provided by one of theplurality of processing modules of the network processor; generate ascheduling hierarchy comprising a tree structure of a root scheduler andN scheduler levels, wherein a scheduler is a branch node and a queue isa leaf node of the scheduling hierarchy, wherein N is a positiveinteger; enqueue each received task in a queue of the schedulinghierarchy associated with the received task, the queue having acorresponding parent scheduler at each of one or more next levels of thescheduling hierarchy up to a root scheduler of the scheduling hierarchy,wherein the queue and one or more corresponding parent schedulers ateach level of the scheduling hierarchy form a branch of the schedulinghierarchy; maintain one or more scheduling data structures for each nodein the scheduling hierarchy; receive a rate reduction requestcorresponding to a given node of the scheduling hierarchy; update one ormore indicators in the scheduling data structure corresponding to thegiven node; and remove the given node from the scheduling hierarchy by acorresponding parent scheduler of the given node, thereby reducing thescheduling rate of the given node.
 20. The network processor of claim19, wherein the network processor is implemented as an integratedcircuit chip.